Microsoft Edge Webdriver sometimes gives the below error when you click on web element in your test code:
This is a known issue and can be traced at:
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5238133/
There's a workaround available till Microsoft Edge team resolves this issue. You can click on the element using javascript in your test. It's an easy to understand three lines of code.
WebElement e = driver.findElement(By.linkText("Check Out"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", e);
Below is an example of a method that uses JavaScript to click on elements:
One important point to take into account is you will have to use explicit or fluent wait statements frequently to give JavaScriptExecuter the time to click on the web element.
This is a known issue and can be traced at:
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5238133/
There's a workaround available till Microsoft Edge team resolves this issue. You can click on the element using javascript in your test. It's an easy to understand three lines of code.
WebElement e = driver.findElement(By.linkText("Check Out"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", e);
- Start with finding the element and storing it in a WebElement object.
- Create JavaScriptExecuter interface reference variable by typecasting the web driver object.
- Call the executeScript method and pass it the script to be executed and web element object from step 1.
Below is an example of a method that uses JavaScript to click on elements:
One important point to take into account is you will have to use explicit or fluent wait statements frequently to give JavaScriptExecuter the time to click on the web element.
No comments:
Post a Comment