将鼠标悬停在图标工具提示上后,我无法获取工具提示文本。我需要获取工具提示文本,这是 html 代码。
<a class="tooltip" onclick="SocialAuth.showOpenIDLoginWindow('google');_gaq.push(['_trackEvent','LoginForm','google-login','google login was clicked']);" href="javascript:void(0);"><span>We dont store your password or access your contacts on your Google account.</span><img class="social" height="39" width="40" src="/images/login/google.png"/>
最佳答案
使用下面的代码行从元素中获取工具提示文本。
String toolTipText = driver.findElement(By.id(element's id)).getAttribute("title");
关于selenium - 如何使用 Selenium WebDriver 获取鼠标悬停时的工具提示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19218404/