Web Elements Using Various Types WebDriver Commands

Introduction

WebDriver has a W3C specification. Those details about information of visibility based out on the types of the web elements.    The visibility of the web elements to check the WebDriver. These web elements can be buttons, dropboxes, checkboxes, radio buttons, labels etc. 1) isDisplayed()   2) isSelected()   3) isEnabled()    

Scenario to be automating

Launch the web browser and open the application under test – http://google.com  

    1. Verify the web page title  
    2. Verify if the “Google Search” buttons display  
    3. Enter the keyword in the “Google Search” text box by which we would want to make the request  
    4. Verify that the “Search button” display and enabled  
    5. Based on visibility of the Search button, click on the search button    

1. isDispalyed()

    isDisplayed() is the method used to verify a web element within the web page. The method design to result from a Boolean value with each success and failure. The method returns a “true” value if the specified web element is present on the web page. A “false” value if the web element is not present on the web page.     Thus the above code verifies for submit button on the Google web page. The returns true values if the submit button are presently visible. The returns a false value, if the submit button, is not present on the web page.  boolean searchIconEnabled = driver.findElement(By.id(“gbqfb”)).isEnabled();    The method deals with the visibility of all kinds of web elements not limiting to any one type.    

2. isEnabled()

    isEnabled() is the method used to verify if the web element enables or disable within the web page. Like isDisplayed() method is designed to result from a Boolean value success and failure. The method returns a “true” value if the specified web element enabled on the web page. A “false” value if the web element is not enabled on the web page. Thus code verifies if the submit button enables or not. The returns a Boolean value depending on the result. The isEnabled() method is significant where we want to learn that only if “Condition A” fulfill. Then the element is enabled refer to the same. Register button enabled only when the agreement checkbox select. We have a method referenced as “isSelected()” tests if the specified web element select or not.     boolean searchIconSelected = driver.findElement(By.id(“male”)).isSelected();    

3. isSelected()

    isSelected() is the method used to verify if the web element select or not. isSelected() method use with radio buttons, dropdowns and checkboxes. It is designed to result from a Boolean value with each success and failure. Thus the above code verifies the male radio button is select or not. The returns a Boolean value depending on the result.