SELENIUM BASICS:


SELENIUM WEBDRIVER:


TESTNG:


REPORTS:


BUILD & CONTINUOUS INTEGRATION TOOLS:


CROSS BROWSER TESTING:


MOBILE TESTING:


AUTOMATION FRAMEWORKS:


API Testing:


INTERVIEW QUESTIONS:


SAMPLE RESUME:

JavaScript Executor in Selenium Python

In the previous articles on Selenium Python Tutorial, we have covered “How to handle checkbox, static dropdowns and other UI elements in Selenium Python“. In this tutorial, we will learn JavaScript Executor in Selenium Python.

Document Object Model or DOM can access all the elements on the web page with the help of Javascript. If we inspect any element on a web page and navigate to the console in the Developer Tools, all the methods available to access the web elements shall be available.

Thus it has the capabilities that Selenium can perform. Selenium has the feature to execute Javascript code [to access the DOM] integrated with it. This is required whenever Selenium cannot identify an element or perform some actions on it.

Selenium contains the execute_script () method to execute Javascript commands which are passed as an argument to that method. Also, while working with DOM methods [getElementsByName and getElementsById and so on] fetch an array of matching elements. So we need to mention the index to locate a particular element. For example: getElementsByName (‘txt-box’) [0], refers to the first matching element on the web page.

Now let us see how to extract values from an edit box with the help of a Javascript executor.

We can also perform click operations on web elements with the help of Javascript executors.

There are some operations like scrolling down a page that cannot be performed with the help of Selenium. For this action, Javascript Executor can be used for this purpose.

We can also retrieve the current URL and title of the webpage with the help of Javascript Executor.

In the next article, we will learn Synchronization in Selenium Python

Related posts:

Sharing is caring.

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

Like This Post?

We have a lot more where that came from?

We only send really good stuff occasionally, promise.

Rajkumar SM

Leave a Comment

Your email address will not be published. Required fields are marked *

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on whatsapp

Recent Posts:

Scroll to Top
API Testing eBook

DOWNLOAD FOR FREE