小编ani*_*tri的帖子

如何使用Selenium在Angular 7应用程序中提取工具提示文本

我正在尝试通过硒在angular7应用程序中阅读文本工具提示。但是获取文本返回空白,而javascript执行程序返回null。

链接到我无法找到xpath的DOM图像

但是获取文本返回空白,而javascript执行程序返回null。

这是空白

driver().get("https://vmware.github.io/clarity/documentation/v0.12/tooltips");
Wait(3000);
System.out.println(driver().findElement(By.xpath("(//span[@class='tooltip-content'])[2]")).getText());
Run Code Online (Sandbox Code Playgroud)

这将返回null

System.out.println(driver().findElement(By.xpath("(//span[@class='tooltip-content'])[2]")).getAttribute("value"));

String theTextIWant = ((JavascriptExecutor) driver()).executeScript("return arguments[0].innerHTML;",driver().findElement(By.xpath("(//span[@class='tooltip-content'])[2]")));
Run Code Online (Sandbox Code Playgroud)

selenium selenium-webdriver angular webdriverwait angular7

1
推荐指数
1
解决办法
299
查看次数