Skip to content Skip to sidebar Skip to footer

Selenium Executescript Hangs On Ie

OK folks, I've searched the web for 2 days to solve the modal dialog problem. Great information out there and it all works except for IE. I'm trying to open a file upload dialog an

Solution 1:

It seems to be related to modal dialog invoked during your argument[0].click operation in IE, see https://code.google.com/p/selenium/wiki/InternetExplorerDriver, section "Clicking Elements or Submitting Forms and alert()", I think it describes same issue.

Few options to try would be:

  1. Replace your with JavaScript code with just "element.click()" or "element.sendKeys(Keys.ENTER)"
  2. Start a new thread before you do argument[0].click, wait in that thread a bit and then run autoIt code

Also you can replace your existing code with JavascriptExecutor to write JavaSrcipt only once:

WebElementelement= driver.findElement(By.name(uploadDifferntFile));
if (driver instanceof JavascriptExecutor) {
  ((JavascriptExecutor) driver).executeScript("arguments[0].click();", element);
}

Solution 2:

I've just stepped in the same problem, because sendKeys wasn't a stable solution for me working with Internet Explorer. So I build a variation with AutoIt.

For Firefox I use the JavaScript and for IE I do a doubleclick on the input field:

// fileInput is the WebElement resulting from the input field with type fileif (browser == "FF") {
    JavascriptExecutorexecutor= (JavascriptExecutor)driver;
    executor.executeScript("arguments[0].click();", fileInput);
} else {
    Actionsaction=newActions(driver);
    ActiondoubleClick= action.doubleClick(fileInput).build();
    doubleClick.perform();
}   

Post a Comment for "Selenium Executescript Hangs On Ie"