java - 使用 selenium 从弹出窗口/通过鼠标悬停在 Web 元素上提取文本

标签 java selenium

enter image description here我需要找到一种方法,如何使用 selenium/java 从弹出窗口获取文本,以便我可以将文本与预期数据进行比较。

无论如何,我可以从弹出窗口中提取文本吗?附截图。提前致谢。

我尝试关注但没有成功

WebElement lMail=driver.findElement(By.xpath("//span[text()='ACE'][@class='footer-title twc-blue twc-roundbook']"));

        new Actions(driver).moveToElement(lMail).perform();


        Actions act = new Actions(driver);
        WebElement age_purpose = driver.findElement(By.xpath("//div[contains(@class, 'popover ng-scope ng-isolate-scope top fade in')]/div/div[@class='popover-inner']"));
        act.moveToElement(age_purpose).perform();
        String tooltiptextreal = age_purpose.getAttribute("innerHTML");[enter image description here][1]

最佳答案

我只是检查该元素是否存在于此 xpath 中。

 //div[.='ACE'][content='Advanced .... 1.24.1']

确保输入所有工具提示文本作为内容属性值。

if(driver.findElements(By.xpath("//div[.='ACE'][content='toolTipTextGoesHere']")).size()>0){
//pass
}else{
//failed
}

关于java - 使用 selenium 从弹出窗口/通过鼠标悬停在 Web 元素上提取文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57860501/

相关文章:

java - 使用 Safari 10/Selenium 3.0.1 删除 cookie 时出现异常

java - 如何将数组中的所有项目除以 double?

java - "duplicate class definition bug occured"在 jboss 中使用 jaxb

python - WebDriverException : Message: unknown error: Chrome failed to start: crashed error using ChromeDriver Chrome through Selenium Python on Amazon Linux

google-chrome - Chrome args 和 prefs 似乎在 Protractor conf 中不起作用

python - 循环并添加到列表

java - Groovy 是否尊重@PostConstruct?

java - 为什么有些带参数的构造函数仍然调用this()?好像什么也没做?

java - 在 equals() 方法中测试泛型类型

java - 当下拉列表包含大量值时,getFirstSelectedOption 需要花费大量时间来返回所选值