How to verify whether Button is enabled or disabled using selenium RC or web driver

9,318 views
Skip to first unread message

sita maram

unread,
May 10, 2012, 1:15:51 AM5/10/12
to seleniu...@googlegroups.com

Hi All,

 is there any method for verifying button is enabled or disabled using web driver or selenium RC. we have isEnabled() method available in web driver but it always returns false when button enabled.

Please provide solution for above scenario.

Thanks,
Ram.

santhosh soma

unread,
May 10, 2012, 1:19:05 AM5/10/12
to seleniu...@googlegroups.com
Hi ,

The developer should maintain one attribute to make that control as enable or disable.

Can you please get that attribute value by the method called getattribute() in webdriver to know that particular element is enable or not.

Thanks
Santhosh.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

sita maram

unread,
May 10, 2012, 1:25:18 AM5/10/12
to seleniu...@googlegroups.com
Hi Santhosh,

 its working, thank you very much.


Thanks,
Ram.
--
Thanks and Regards,
M.Sitaramireddy.

sindhu anjali

unread,
May 10, 2012, 2:03:35 AM5/10/12
to seleniu...@googlegroups.com
Hi Sita,
 I am also facing same problem. Can u please post the details how u resolved the issue.

Thanks in advance:)

sita maram

unread,
May 10, 2012, 2:42:42 AM5/10/12
to seleniu...@googlegroups.com
Hi sindhu,
 
actually there is method to verify button status in selenium RC and web driver, but we need to verify whether button disabled or enabled. so, in my application developers provided "Disabled" property.

when button got disabled, plz find below firebug code:
<button class="x-btn-text " style="position: relative; width: 44px;" type="button" tabindex="0" aria-disabled="true">OK</button

when button got enabled, plz find below firebug code:
<button class="x-btn-text " style="position: relative; width: 44px;" type="button" tabindex="0" aria-disabled="false">OK</button

my code:

if(Globals.driver.findElement(By.xpath("//button[text()='OK']")).getAttribute("aria-disabled").equals("false")){
        Globals.driver.findElement(By.className("x-panel-btns")).findElement(By.xpath("//button[text()='OK']")).click();
      }
else{
    Globals.driver.findElement(By.className("x-panel-btns")).findElement(By.xpath("//button[text()='Cancel']")).click();

}

Please let me know if more required.

Thanks,
Ram

sindhu anjali

unread,
May 10, 2012, 2:57:13 AM5/10/12
to seleniu...@googlegroups.com
Thanks for quick reply.
Now i got clear idea about implemention

chiru k

unread,
May 13, 2012, 12:04:10 AM5/13/12
to seleniu...@googlegroups.com
your explanation was very good

but could you please tell me you were using 2 time findelement method in single line how it works and tell me the first classname you were using is not in the code i am interesting to know more if you free please tell me

this is the class name in the code     class="x-btn-text "  but you were using the
 By.
className("x-panel-btns"))

sita maram

unread,
May 14, 2012, 12:34:39 AM5/14/12
to seleniu...@googlegroups.com
Hi,

here i have to click on "OK" button in sub frame( there are two ok buttons existes in main frame and sub frame) so i was written like that.


Please let me know if you have any concerns.

Thanks,
Ram.

Santhosh Surimani

unread,
Jan 27, 2017, 1:07:55 AM1/27/17
to Selenium Users, maram...@gmail.com
Hi All,

Can anyone tell me how to remove disabled property from input tags, since the attributes of input tags (like name and id) are dynamic, and not able to provide  static attribute values to get the disabled tag.

Sample html code snippet below.

<form>
  <fieldset disabled>
    <legend>Personalia:</legend>
    Name: <input type="text" name="uname"><br>
    Email: <input type="text" name="pwd"><br>
    Date of birth: <input type="text" name="dob">
  </fieldset>
</form> 
Reply all
Reply to author
Forward
0 new messages