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/