-3

How to handle the error Page reload detected during async script using Selenium and InternetExplorerDriver?

Error stack trace:

org.openqa.selenium.JavascriptException: Page reload detected during async script
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_221'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities {acceptInsecureCerts: false, browserName: internet explorer, browserVersion: 11, javascriptEnabled: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), se:ieOptions: {browserAttachTimeout: 0, elementScrollBehavior: 0, enablePersistentHover: true, ie.browserCommandLineSwitches: , ie.edgechromium: false, ie.edgepath: , ie.ensureCleanSession: false, ie.fileUploadDialogTimeout: 3000, ie.forceCreateProcessApi: false, ignoreProtectedModeSettings: false, ignoreZoomSetting: false, initialBrowserUrl: http://localhost:24135/, nativeEvents: true, requireWindowFocus: false}, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: f8538187-14df-4144-8bd0-605ce398395e
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.executeAsyncScript(RemoteWebDriver.java:506)
    at stepdefinition.Steps.I_selected_the_Client(Steps.java:60)
Yu Zhou
  • 11,532
  • 1
  • 8
  • 22

3 Answers3

1

This error message...

org.openqa.selenium.JavascriptException: Page reload detected during async script 
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' 
System info: os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_221' 
Driver info: org.openqa.selenium.ie.InternetExplorerDriver

...implies that the InternetExplorerDriver was unable to interact with the Browsing Context i.e. InternetExplorer Browser session.

A bit more details interms of:

  • Selenium binding art i.e. Protractor / Java / Python / C#.
  • Selenium client version.
  • InternetExplorerDriver version.
  • Relevant HTML (if applicable).

Would have helped us to construct a canonical answer.

However, if you are using Protractor as per the documentation in Page reload detected during async script, this error implies:

There was a navigation or reload event while a command was pending on the browser. Usually, this is because a click action or navigation resulted in a page load. Protractor is trying to wait for Angular to become stable, but it's interrupted by the reload.

Solution

As a solution, you may need to insert a browser.wait condition to make sure the load is complete before continuing.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

Could you please provide a minimal sample to reproduce the issue? With which code snippet you're running and in which line the error occurs? You could follow the below sample to automate IE using Selenium webdriver in Java:

import org.openqa.selenium.By;     
import org.openqa.selenium.WebDriver;     
import org.openqa.selenium.ie.InternetExplorerDriver;     
import org.openqa.selenium.WebElement; 

public class new_java_class {              
public static void main(String[] args) {     
  //add the IE web driver path here..     
  System.setProperty("webdriver.ie.driver","your\\path\\to\\IEwebdriver\\IEDriverServer.exe");              
       WebDriver browser = new InternetExplorerDriver();     
       //replace the URL of the web page here..     
       browser.get("http://testsite.login/");                     
       WebElement username = browser.findElement(By.name("uname"));      
       username.sendKeys("test_user");                     
       WebElement password = browser.findElement(By.name("psw"));        
       password.sendKeys("abcd@1234");                     
       WebElement btn = browser.findElement(By.name("signIn"));      
       btn.click();                     
}              
} 
Yu Zhou
  • 11,532
  • 1
  • 8
  • 22
0

issue got resolved by using the CSS locator instead of AsynScript to perform click action on webelement. Thank You

  • Thanks for posting the solution. You could mark it as an accepted answer after 48 hrs, when it is available to mark. It can help other community members in future in similar kind of issues. Thanks for your understanding. – Yu Zhou Feb 17 '20 at 01:42