I am using selenium webdriver with java to write the script. However, we have few fields which are getting disabled after click on button. We need to find this field are getting readonly mode or not. I have use isEnabled
and isDisplayed
but it is not working, the system displays NoSuchElementFound
expection. Is there any way to handle this?
You can achieve this without having to execute JS, all you need to do is to get the DOM Attribute of the element which is "ReadOnly" this can be achieved using:
WebElement readOnly = driver.findElementBy(locator);
Assert.assertTrue(readOnly.getAttribute("readOnly").equals("true"),"Element ReadOnly")
Hope this helps....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With