'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



Solution 1:[1]

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(); }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kedar