我有一个 web 元素,它在鼠标悬停时显示一些文本(它不是工具提示),html 代码是
<div class="total-discout-outer" style="display: block;">
<div class="total-discout-show">
<div class="discount-arrow-top"></div>
<div style="line-height:12px;font-size:13px;"> Promo Applied: (-) Rs 2</div>
</div>
</div>
现在只要鼠标在这里或那里移动一点,文本就会消失,因为它是
<div class="total-discout-outer" style="display: none;">
<div class="total-discout-show">
<div class="discount-arrow-top"></div>
<div style="line-height:12px;font-size:13px;"> Promo Applied: (-) Rs 2</div>
</div>
</div>
我尝试为它生成 xpath 并使用 XPathChecker 检查它工作正常,但使用 selenium 它给出 NoSuchElement 异常
我使用的 xpath 是
//div[contains(@style,'display: none')]//div[contains(text(),'Promo')]
我也试过
Actions builder = new Actions(driver);
builder.moveToElement(driver.findElement(By.xpath("//div[@class='discounted-price']"))).build().perform();
System.out.println(driver.findElement(By.className("total-discount-show")).getText());
“折扣价”是悬停时显示促销文本的 web 元素,但上面也给出了 NoSuchElementException。现在我如何从中获取文本。