Friday, February 9, 2018

how to verify if WebElement exists in selenium webdriver

You can use any of the below 3 functions to verify if a particular web element exists in your web application using selenium web driver.

Sample code for the same looks like below:

driver.findElement("your locator code here").isDisplayed();

This function returns Boolean value "TRUE" if the web element as per the locator exists and displayed in your application. else it will return False.

In the same way, you can use isSelected(), isEnabled() functions to check if a web element is selected or enabled in your web application. 

No comments:

Post a Comment