java - 如何使用 Java 验证 Selenium WebDriver 中的 tooltipText

标签 java tooltip selenium-webdriver

我有以下 HTML 代码片段:

<div style="float:right; padding-right: 50px; margin-top: -10px;" id="divTooltips">
<img width="25px" height="25px" src="/mkteditor/css/images/tooltip.png" alt="">
</div>

在将鼠标悬停在 tooltip.png 上时,会显示工具提示文本“顶部的帮助文本”。我想验证 WebDriver 中的 tooltipText。怎么做?

最佳答案

只要你有工具提示,“title”属性就会出现。 (根据我的观察)。

例如:转到http://www.linkedin.com/并在顶部查看 LinkedIn 图片的 HTML 代码。 领英

    WebDriver driver = new InternetExplorerDriver();
    driver.get("http://www.linkedin.com/");
    WebElement onElement = driver.findElement(By.xpath("html/body/div[1]/div[1]/div/h2/a"));
    System.out.println("Tooltip : " + onElement.getAttribute("title"));

关于java - 如何使用 Java 验证 Selenium WebDriver 中的 tooltipText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13133185/

相关文章:

java - DateTimeFormatter 自动更正无效(语法上可能)的日历日期

css - 如何防止 Kendo UI 饼图工具提示在父 Div 之外绘制?

wpf - 选项卡标题中选项卡控件的工具提示

JQuery 工具提示不显示

java - 使用 Selenium 2 将本地镜像注入(inject)/加载到当前网页

java - 如何使用java以编程方式获取SVG文档中的形状宽度

java - 转换 EEE MMM dd HH :mm:ss ZZZ yyyy to YYYY-MM-dd JAVA

Java - 创建和移动 xml : cannot access the file because it is being used by another process

javascript - 使用 WebDriver 或 WebDriverJS 同时处理两个浏览器

java - 使用 Selenium 独立服务器 3.9.1 在 Eclipse Photon 中导入时出现 "The import org cannot be resolved"错误