硒测试由于org.openqa.selenium.NoSuchSessionException而失败:会话ID无效

时间:2020-06-25 09:03:17

标签: selenium selenium-webdriver automated-tests selenium-chromedriver ui-automation

    org.openqa.selenium.NoSuchSessionException: invalid session id
    Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:25:02.294Z'
    System info: host: 'chaos', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-957.21.3.el7.x86_64', java.version: '1.8.0_121'
    Driver info: org.openqa.selenium.chrome.ChromeDriver
    Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 83.0.4103.106, chrome: {chromedriverVersion: 83.0.4103.39 (ccbf011cb2d2b..., userDataDir: /tmp/.com.google.Chrome.XiR2sj}, goog:chromeOptions: {debuggerAddress: localhost:37450}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
    Session ID: cf2b9146e49c20dccbba70b575b2a393
        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:160)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
        at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:325)
        at com.tomtom.workflow.iris.uitest.pages.LoginService.logout(LoginService.java:66)

在登录/登录到应用程序时出现此问题。 我也验证了chrome版本/浏览器的兼容性。 由于这个原因,一些tome测试运行良好,而有时候多次测试却失败了。

我尝试过的选项:

      checked Chrome driver compatibility: 
      browserVersion: 83.0.4103.106,chromedriverVersion: 83.0.4103.39

      I have also checked the test;there is no use of driver.quit() and 
      driver.close()

      Selenium server version is "3.141.59".
      JDK version is "1.8".

执行以下代码时出现问题:

      public void logout(String url) throws URISyntaxException {

    // when user is logged out
    URIBuilder uri = new URIBuilder(url);
    uri.setPath("uiris/logout");

    **$.driver().get().get(uri.toString());** //this line is causing the 
     issue.

    $("*[id='login.signIn']").waitUntil(5000).isPresent();
    LOG.info("log out is done successfully.");
} 

我无法理解问题所在。

 The issue is not reproduced, if the tests are run on the local machine. But 
 when tests are running on two different Jenkins created machines in 
 parallel, then multiple tests are getting failed due to this problem only on 
 one machine. 
    

有人可以帮我吗?

0 个答案:

没有答案