Как обработать ошибку «Перезагрузка страницы обнаружена во время асинхронного c сценария» с использованием Selenium - PullRequest
0 голосов
/ 12 февраля 2020

Как обработать ошибку Page reload detected during async script с помощью Selenium и InternetExplorerDriver?

Трассировка стека ошибок:

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)

Ответы [ 3 ]

1 голос
/ 12 февраля 2020

Это сообщение об ошибке ...

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

... означает, что InternetExplorerDriver не смог взаимодействовать с Контекстом просмотра т.е. InternetExplorer Браузер сессия.

Немного более подробной информации interms of:

  • Селиновый переплет, т.е. Транспортир / Java / Python / C#.
  • Selenium версия клиента.
  • InternetExplorerDriver версия .
  • Соответствует HTML (если применимо).

Помогло бы нам построить канонический ответ.

Однако, если вы используете Транспортир согласно документации в Обнаружена перезагрузка страницы во время асинхронного c сценария , эта ошибка подразумевает:

Произошло событие навигации или перезагрузки, когда команда находилась на рассмотрении в браузере. Обычно это происходит потому, что действие щелчка или навигация приводят к загрузке страницы. Транспортир пытается подождать, пока Angular станет стабильным, но перезагружается.

Решение

В качестве решения может потребоваться вставить условие browser.wait перед продолжением убедитесь, что загрузка завершена.

0 голосов
/ 15 февраля 2020
Проблема

была решена с помощью локатора CSS вместо AsynScript для выполнения действия щелчка по webelement. Спасибо

0 голосов
/ 14 февраля 2020

Не могли бы вы предоставить минимальный образец для воспроизведения вопроса? С каким фрагментом кода вы работаете и в какой строке происходит ошибка? Вы можете использовать приведенный ниже пример для автоматизации IE с помощью веб-драйвера Selenium в 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();                     
}              
} 
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...