How to check the link is enabled in Webdriver using java?

925 views
Skip to first unread message

Umamaheshwar Thota

unread,
Aug 7, 2013, 9:13:21 AM8/7/13
to webd...@googlegroups.com


I have searched the forums before posting this issue here. I have found some answers but i am not able to get the success from the answers in that. My issue is

How to check the link is enabled in Web driver using java. Please find the attached screen shots for the same.

I have written the code for this:

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");

Please help me out with this issue. Help will be appreciated.

Thanks,

Mahesh

Application.png
Code for View link.png

Sean Adkinson

unread,
Aug 7, 2013, 11:55:21 AM8/7/13
to webd...@googlegroups.com
Seems like the isEnabled() should work, but based on the HTML you show, you could also just use textLink.getAttribute("disabled"), and look at the value.

darrell

unread,
Aug 8, 2013, 8:18:57 PM8/8/13
to webd...@googlegroups.com
I'm not sure which version of HTML this document is but the anchor from HTML5 and HTML 4.01 do not have a disabled attribute. I would suspect this is a non-standard way to disable an anchor. If you read the Selenium API documentation for isEnabled() you will see "This will generally return true for everything but disabled input elements."

So if the web application is using a non-standard way of disabling anchors, you have to write your own method to check for disabled. You can write a method which checks anchors for the "disabled" attribute.

Darrell
Reply all
Reply to author
Forward
0 new messages