Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JAVA验证SeleniumWebDriver中是否启用了链接?_Selenium_Webdriver_Testng - Fatal编程技术网

如何使用JAVA验证SeleniumWebDriver中是否启用了链接?

如何使用JAVA验证SeleniumWebDriver中是否启用了链接?,selenium,webdriver,testng,Selenium,Webdriver,Testng,我想先验证是否启用了分页链接。如果是 已启用,然后单击链接,否则我不想单击 在JAVA中链接并跳过if条件 我正在使用SeleniumWeb驱动程序和TestNG 谢谢, Rishil Bhatt使用浏览器inspect元素的web控制台检查是否有任何属性可使用样式、类等禁用链接 String temp = selenium.getAttribute(locator@attribute); 现在您可以验证temp的值 请同时参考:使用isEditable(定位器),如果链接被禁用,将返回fa

我想先验证是否启用了分页链接。如果是 已启用,然后单击链接,否则我不想单击 在JAVA中链接并跳过if条件

我正在使用SeleniumWeb驱动程序和TestNG

谢谢,
Rishil Bhatt

使用浏览器inspect元素的web控制台检查是否有任何属性可使用样式、类等禁用链接

String temp = selenium.getAttribute(locator@attribute); 
现在您可以验证temp的值

请同时参考:

使用isEditable(定位器),如果链接被禁用,将返回false,否则返回true

if(existsElement("test")==true){
WebElement menuHoverLink = driver.findElement(By.id("test"));
actions.moveToElement(menuHoverLink).perform();
Thread.sleep(6000);
}
else{
System.out.println("element not present -- so it entered the else loop");
}
然后在测试中调用该方法:

homePage.elementIsDisable(driver, By.id("acc-confirm"));

此检查是否禁用webElement

当链接处于“启用”状态和“禁用”状态时,是否可以发布HTML代码。我试图理解你说“启用”是什么意思。通常它要么在那里,要么不在那里,你不能真正禁用它。
homePage.elementIsDisable(driver, By.id("acc-confirm"));