Home > Automation Testing > JavaScriptExecutor in Selenium

JavaScriptExecutor in Selenium

Javascript executor is used to execute javascript from selenium. Actions which need to be performed forcibly can be performed using javascript executor. For example selenium not able to click on particular web element due to disable state of it but our requirement is to click on that element. In this case we can use JavascriptExecutor.

Javascript executor should not be used if operation on webelement can be performed using selenium. For instance if element is clickable by driver.findElement(“Locator”).click(); then we should not use JavaScriptExecutor.

Most of the time JavaScriptExecutor is used for scrolling into particular x and y location. And clicking on disabled element.

Syntax of javascript executor:

Example: Below code opens www.mundrisoft.com and it scrolls to 50,1500 location.

 

This Article is TAGGED in , , , . BOOKMARK THE permalink.

Amit Bharamasali
Automation Software Test Engineer. Skills: Manual Testing, Selenium, Java, Protractor, JavaScript, Katalon Studio, Groovy, Appium, Sahi, Sahi Script and UI/UX testing.

Leave a Reply

Your email address will not be published.

two + six =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">