kedar
kedar

Reputation: 11

HOW TO USE JavascriptExecutor in Microsoft edge using java and selenium

We have automation project we need to click menu items we use this below code

((JavascriptExecutor) test.getDriver()).executeScript("mCLICK(arguments[0]);", substr);

its is working well in chrome browser we want migrate to edge . we are running the same code in micro soft Edge browser it's giving the below error

Exception class:org.openqa.selenium.JavascriptException the reason is:org.openqa.selenium.JavascriptException: javascript error: Function is not a constructor.

Pls advise

Upvotes: 0

Views: 167

Answers (1)

kedar
kedar

Reputation: 11

I found the answer for click event for edge browser i put condition based on the browser

if(!browser.equals("edge")) { String substr = child.getAttribute("substr");

    ((JavascriptExecutor) 

test.getDriver()).executeScript("mCLICK(arguments[0]);", substr); } else { test.getDriver().findElement(By.name(items[0])).click(); Thread.sleep(2000); test.getDriver().findElement(By.name(items[1])).click(); Thread.sleep(3000); test.getDriver().findElement(By.name(items[2])).click(); }

Upvotes: 0

Related Questions