This is a late answer, but since I am working on it recently, I would like to share my solution.
I implemented a check method if the text field is read-only or not. I am working on a Django project, so the code is in Python, but I find it easy to port to Java:
from django.contrib.staticfiles.testing import StaticLiveServerTestCase class MyTest(StaticLiveServerTestCase): def setUp(self): self.browser = webdriver.Firefox() def _is_text_box_read_only(self, web_element): old_text = web_element.get_attribute("value") web_element.send_keys("test") new_text = web_element.get_attribute("value") web_element.clear() web_element.send_keys(old_text)
Note that:
- To get the entered text, you need to use the
value
attribute. - It is better to return to the previous text after testing.
- Code is just an excerpt that shows the main ideas. It cannot be started.
source share