在此处发布此问题之前,我已经搜索了论坛。我找到了一些答案,但我无法从其中的答案中获得成功。我的问题是
如何使用 java 检查 Webdriver 中的链接是否启用。请查找所附的相同屏幕截图。
我已经为此编写了代码:
WebElement textlink = driver.findElement(By.id(OR.getProperty("lnkView_ID")));
if (textlink.isEnabled())
System.out.println("View link: Enabled");
else
System.out.println("View link: Disabled");
请帮我解决这个问题。我们将不胜感激。
最佳答案
尝试以下操作:
String isDisabled = textlink.getAttribute("disabled");
if (isDisabled==null || !isDisabled.equals("disabled")){
System.out.println("View link: Enabled");
}else{
System.out.println("View link: Disabled");
}
看起来属性“disabled”是其是否启用的开关,因此您可以使用 getAttribute();
关于java - 如何使用java检查Webdriver中的链接是否启用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18104259/