我可以单击的对象,单击时,什么也没有发生,即该操作被禁用。但是,将显示工具提示。仅当我们将焦点放在按钮上时,工具提示才会出现。
按钮的html如下:
import os, subprocess
subprocess.run(['app', '--email', 'some-email', '--password', 'somepassword'], cwd=os.path.expanduser('~/app-cli'))
“骑乘”只能在其中编辑的地方是工具提示。
随着工具提示的文本不断被破坏,我该如何验证它。
请注意,isEnabled()函数在此处返回true,因为我可以单击按钮,但不会执行任何操作。
有什么方法可以验证按钮的类别,即btn btn-default disbleBtn width_100吗? 有任何功能或方法吗?
答案 0 :(得分: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)