Check enability of a button when "enabled" attribute is not present. Selenium webdriver

1,958 views
Skip to first unread message

sanam

unread,
Mar 4, 2013, 2:17:43 AM3/4/13
to seleniu...@googlegroups.com
Hi,

   I am using selenium webdriver(V 2.25). In my application I have a button.I need to check the enability of this button.
However, there is no "enabled" attribute for this button. The properties is like below.

If the button is enabled

<input type=button name=button1 title=my button onclick()= dosomething()>

If the button is disabled 

<input  type=button name=button1 title=my button>

The difference is that there are no events when the button is disabled.

Please suggest how to check for the enability when there is NO enabled attribute.
I tried using the webdriver function isenabled() , but this always returns true.

Thanks,
Sanam

munee...@gmail.com

unread,
Mar 4, 2013, 3:52:46 AM3/4/13
to seleniu...@googlegroups.com
I am sure the method isEnabled() does what you are looking for.

sanam

unread,
Mar 4, 2013, 5:17:11 AM3/4/13
to seleniu...@googlegroups.com
Hi,

The isenabled is returning true even when the button is disabled.

Mike Hill

unread,
Mar 4, 2013, 5:32:22 AM3/4/13
to seleniu...@googlegroups.com
i'm unsure of your testing framework, but in mine (nunit) i would write this


Assert.IsTrue(YOURCODEHERE); 

This is because isEnabled() is a boolean. You will need to handle that boolean result.

Mark Collin

unread,
Mar 4, 2013, 5:51:48 AM3/4/13
to seleniu...@googlegroups.com
Show us your code.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/kRZ1mgoGU1EJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

sanam

unread,
Mar 4, 2013, 7:11:12 AM3/4/13
to seleniu...@googlegroups.com
Hi Mark,

             My code is like that

Webelement element=driver.findelementbyxpath(//xpath)
boolean isEnabled =element.isEnabled()


This is returning as true even when the element is disabled.

The html of the app is like this.
1) When the button is enabled

<input name="Legend" title="Mass Scheduling" class="masSchBut masSchButdn" id="Legend" onmouseover="this.className = 'masSchBut masSchButdn'" onmouseout="this.className = 'masSchBut masSchButnor'" onclick="JavaScript:displayMassApptScreen();" type="button"/>

2) When the button is disabled

<input name="Legend" title="Mass Scheduling" class="masSchBut masSchButIs" id="Legend"  type="button"/>

please notice that the class names are different in both the cases and events are not present when the button is disabled.

Thanks,
Sanam

Debasish Dutta

unread,
Mar 4, 2013, 7:17:18 AM3/4/13
to seleniu...@googlegroups.com
Hi sanam,
try this may it will work for you.

Webelement element=driver.findelementbyxpath(//xpath);
boolean bool=element.getAttribute("enabled"); //it may return true or false





--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/V2xWEfJ2-BUJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

Thanks & Regards,

Debasish Dutta
Reply all
Reply to author
Forward
0 new messages