InterviewSolution
Saved Bookmarks
| 1. |
How to know the element is enabled or not? |
|
Answer» During test case creation, you NEED to frequently verify that the targeted element is enabled or DISABLED on the web page before performing any action on it. Selenium WebDriver has built-in isEnabled() method to CHECK whether the status of the element is enabled on the web page. If the specified element is enabled, isEnabled() method of WebDriver will verify and return true, ELSE will return false. Syntax is - driver.findElement(By.xpath(“//input[@name=’fname’]“)).isEnabled();To take some action based on the element’s enabled status, we can use the isEnabled() method with if condition to take action. //verify name TEXT box is enabled or not If (FirstName.isEnabled ()) { System.out.print ( “Text box First name is enabled. ”); } Else { System.out.print ( “Text box First name is disabled. ”) } |
|