While executing automation scrits written n selenium using cucumber frame work iam getting the below exception
org.openqa.selenium.WebDriverException:
unknown error: Cannot read property 'defaultView' of undefined
Previously befor spring 19 release the scripts where passed .After spring 19 scripts are failing and showing ablve exception
public void waitForElementToBeDisplayed(WebElement element) {
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
LOGGER.info("element is " +element);
LOGGER.info(String.format("Waiting for WebElement '%s' to be displayed", element.toString().replaceAll(".*-> ", "").replace("]", "")));
element = new WebDriverWait(driver, 40).until(ExpectedConditions.visibilityOf(element));
Assert.assertTrue(element.isDisplayed());
}
I had similar Exception on-click event. So I used a workaround. I wait for element to be clickable and then trying to click on it with js.
wait.until(ExpectedConditions.elementToBeClickable(STORE_ADMINISTRATION_LOCATOR));
// driver.findElement(STORE_ADMINISTRATION_LOCATOR).click(); <== this line returns
// WebDriverException: unknown error: Cannot read property 'defaultView' of undefined
// replaced with
WebElement element = driver.findElement(STORE_ADMINISTRATION_LOCATOR);
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With