Java 我们应该在使用Actions类悬停之前还是在悬停之后获取工具提示文本?
如果我重复这个问题,我道歉。我已经在这个网站上找到了很多答案,但我仍然没有得到工具提示文本。 如果不使用Actions类将鼠标悬停在工具提示上方并显示工具提示,我可以阅读标题。 但是,一旦我使用Actions类来显示工具提示,则标题始终为空。我不想在我离开之前得到文本 悬停在上面,不是阅读显示的工具提示文本的全部想法吗Java 我们应该在使用Actions类悬停之前还是在悬停之后获取工具提示文本?,java,selenium-webdriver,tooltip,mouseover,webdriverwait,xpath,Java,Selenium Webdriver,Tooltip,Mouseover,Webdriverwait,Xpath,如果我重复这个问题,我道歉。我已经在这个网站上找到了很多答案,但我仍然没有得到工具提示文本。 如果不使用Actions类将鼠标悬停在工具提示上方并显示工具提示,我可以阅读标题。 但是,一旦我使用Actions类来显示工具提示,则标题始终为空。我不想在我离开之前得到文本 悬停在上面,不是阅读显示的工具提示文本的全部想法吗 driver.get("https://jqueryui.com/tooltip/"); WebElement frame = driver.findEl
driver.get("https://jqueryui.com/tooltip/");
WebElement frame = driver.findElement(By.xpath("//iframe[@src='/resources/demos/tooltip/default.html']"));
driver.switchTo().frame(frame);
WebElement element = driver.findElement(By.id("age"));
Actions actions = new Actions(driver);
actions.moveToElement(element).perform(); (I've also tried clickAndHold method)
WebElement toolTip = driver.findElement(By.xpath("//*[@id='age']"));
// To get the tool tip text and assert
String toolTipText = toolTip.getAttribute("title");
System.out.println("toolTipText-->"+toolTipText);
仅在执行后提取
要打印,请将字段悬停以查看工具提示。由于所需元素位于
中,您需要:
scrollIntoView()
- 诱导所需的帧可用并切换到它
- 归纳所需元素的ElementLocated()的可见性
- 针对需要从中检索以下内容的元素的visibilityOfElementLocated():
- 您可以基于以下内容使用:
- 控制台输出:
We ask for your age only for statistical purposes.
中,只有当您将鼠标悬停在触发事件的文本框上时才可见。谢谢,这很有意义
We ask for your age only for statistical purposes.