Python Selenium
About Lesson

In this Python Selenium tutorial we want to learn about Verify Displayed Web Elements in Python Selenium, there are three methods in selenium web driver that we can check the visibility of the web elements in Python Selenium, we have is_displayed(), is_enabled() and is_selected(). so some times we need to verify the displayed element in a web page, when we are going to automate our web pages, some times we need to find that some web elements are displayed on a web page or some web elements are enabled in a web page.

 

 

 

is_displayed() method

The is displayed action verifies if an element is displayed on the web page and can be executed on all web elements. the is_displayed() method returns a boolean value specifying whether the target element is displayed or not displayed on the web page.

following is the code to verify if the Google Input field is displayed or not,  which obviously should return true in this case.

 

In the above example we have found the targeted web element using XPath, and after that we have used the is_displayed() method from selenium web driver to check the element.

 

 

Run the code and we are receiving true in the console, because the web element is displayed in the page.

Python Selenium Verify Displayed Web Elements
Python Selenium Verify Displayed Web Elements

 

 

 

 

is_enabled method()

The is enabled action verifies if an element is enabled on the web page and can be executed on all web elements. the is_enabled() method returns a Boolean value specifying whether the target element is enabled or not displayed on the web page.

 

The following is the code to verify if the Google Input Field is enabled or not,  which obviously should return true in this case.

The preceding code uses the is_enabled() method to determine if the element is  displayed on a web page. The preceding code returns true for the Google Input Field.

 

 

 

Run the code and you will receive true.

Python Selenium is_enabled
Python Selenium is_enabled

 

 

 

is_selected() method

The is_selected() action verifies if an element is selected right now on the web  page and can be executed only on a radio button, options in select, and checkbox  web elements. When executed on other elements, it will return false.

 

The preceding method returns a Boolean value specifying whether the target element  is selected or not selected on the web page.

 

The preceding code uses the is_selected() method. and we have two checkboxes, one is selected and the second is not selected.

 

 

Run the code and this is the result 

Python Selenium Is Selected
Python Selenium Is Selected
Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.
Exercise Files
No Attachment Found
No Attachment Found