【问题标题】:Selenium tests are failing due to org.openqa.selenium.NoSuchSessionException: invalid session id on two different machineSelenium 测试因 org.openqa.selenium.NoSuchSessionException 失败:两台不同机器上的无效会话 ID
【发布时间】:2020-10-19 05:05:05
【问题描述】:
    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 版本/浏览器的兼容性。 由于这个原因,一些大部头测试运行良好,但有时多个测试会失败。

我尝试过的选项:

      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. 
    

我无法识别,如果运行测试的机器有问题,或者 chrome 驱动程序有问题。

有人可以帮我吗?

【问题讨论】:

  • 你能把$.driver().get().get(uri.toString());改成$.driver().get(uri.toString());重新测试吗?
  • 你如何确保你没有打电话给driver.close()?如果您并行运行测试,您的测试可能会使用正在关闭的共享驱动程序,而另一个测试仍在运行。
  • @AlexeyR。我检查了测试代码。代码中没有使用 driver.close()。相反,在从应用程序执行每次测试注销后,并在开始登录应用程序时执行。
  • $.driver().get(uri.toString()) 对我不起作用。我试过$.url(uri.toString());,它对我有用。谢谢!!!!

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


【解决方案1】:

问题是两台机器都使用相同的 chrome 会话

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多