Python Selenium is_displayed and is_enabled Method

This is our fourth article in Python Selenium, in this article we are going to learn about Selenium is_displayed(), is_enabled() Method also we are going to learn about is_selected() Method. 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. there are three methods that you can use is_displayed(), is_enabled() and is_selected() Method, that we are going to talk about these methods .

 

 

 

Python Selenium Articles

1: Python Selenium Introduction & Installation 

2: Python Selenium Web Elements Introduction

3: Python Selenium Web Driver Commands 

 

 

 

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.

 

 

The following is the code to verify if the Google Search button is displayed or not,  which obviously should return true in this case:

 

The preceding code uses the isDisplayed() method to determine if the element  is displayed on a web page.

The preceding code returns true for the Google  Search button.

 

 

 

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 Search button is enabled or not,  which obviously should return true in this case:

 

The preceding code uses the isEnabled() method to determine if the element is  displayed on a web page. The preceding code returns true for the Google Search  button.

 

 

 

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  WebElements. 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 isSelected() method. It returns false for the Google  Search button, because this is not a radio button, options in select, or a checkbox.

 

 

 

So now this is the complete code for  Python Selenium is_displayed and is_enabled Method

 

 

 

 

 

Also you can watch the complete video for Python Selenium is_displayed and is_enabled Method

Subscribe and Get Free Video Courses & Articles in your Email

 

Share via
Copy link
Powered by Social Snap
×