How to check one field is editable or not?

7,471 views
Skip to first unread message

Sudhansu Sekhar panda

unread,
Feb 20, 2015, 1:59:08 AM2/20/15
to seleniu...@googlegroups.com
Hi All,

How to verify that one field is editable or not??

My approach: I am retrieving the text putting in a String after that i am sending keys to that field to edit the text. And after sending keys i am retrieving the text for that element and comparing the text it should not be changed. It is working fine in FF and but not working in IE.

Approach #2: I can do it by taking  the readonly attribute but there is no "readonly" attribute for that element in HTML.

WebElement some_element = driver.findElement(By.id("id"));
    String readonly = some_element.getAttribute("readonly");
    Assert.assertNotNull(readonly);

Is there any other way to handle this?

Thanks,

Sudhansu

Doug Dragon

unread,
Feb 21, 2015, 12:15:55 AM2/21/15
to seleniu...@googlegroups.com
Hi,
Depending on how the field is displayed, you might be able to use the 'disabled' attribute? Something like this:
String readonly = some_element.getAttribute("disabled");

Hope that helps,

-Doug

Xiang Dong

unread,
Feb 21, 2015, 7:38:15 AM2/21/15
to seleniu...@googlegroups.com
Try retrieve value instead of text with approach 1.


Date: Fri, 20 Feb 2015 21:15:55 -0800
From: thatd...@gmail.com
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: How to check one field is editable or not?
--
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/msgid/selenium-users/ed7f3cb8-673f-45a6-8c7f-ffca1d6509a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

murali seleniumtrainer

unread,
Feb 22, 2015, 4:00:27 AM2/22/15
to seleniu...@googlegroups.com
Hi,

I hope by seeing HTML code, i can try to help you...

any how, did you tried with isEnabled ? something like
driver.findElement(By.xpath("//element")).isEnabled() == false

let me now, it works or not..

Thank You
Reply all
Reply to author
Forward
0 new messages