selenium测试非活动按钮的工具提示

问题描述 投票:0回答:1

我可以点击,点击,没有任何反应,即动作被禁用。但是,会显示工具提示。仅当我们关注按钮时才会显示工具提示。

按钮的html如下:

     <button type="button" style="color:#ffffff;" rel="rel-517347" data-toggle="popover" data-animation="true" data-placement="top" data-html="true" data-trigger="hover" data-content="<span class='text-center'>
    <div>Ride can only be edited before </div><div>1 hour of pickup time.</div>
</span>" class="btn btn-default disbleBtn width_100" data-original-title="" title="">Edit Ride</button>

只能在工具提示之前编辑Ride。

我如何验证工具提示的文本,因为它不断被破坏。

请注意,isEnabled()函数在此返回true,因为我可以单击按钮,但不会执行任何操作。

有什么方法可以验证按钮的类,即btn btn-default disbleBtn width_100?它有什么功能或方法吗?

selenium button webdriver tooltip
1个回答
0
投票

我想你需要悬停而不是点击按钮。显示悬停工具提示时,立即单击并且工具提示消失。使用chrome devtools手动执行,打开devtools-> sources选项卡,将鼠标悬停在按钮上,然后按F8暂停,然后检查工具提示元素。获得工具提示的选择器后,请尝试以下代码:

new Actions(driver).moveToElement(buttonElement).perform();
String tooltipText = new WebDriverWait(driver, 10)
    .until(ExpectedConditions.visibilityOfElementLocated(toolTipLocator).getText();
//Verify

或试试这个:

new Actions(driver).moveToElement(buttonElement).perform();
new WebDriverWait(driver, 10)
    .until(ExpectedConditions.textToBePresentInElementLocated(toolTipLocator, textToVerify)
© www.soinside.com 2019 - 2024. All rights reserved.