Java org.openqa.selenium.NoSuchSessionException:没有这样的会话

Java org.openqa.selenium.NoSuchSessionException:没有这样的会话,java,google-chrome,selenium,selenium-webdriver,selenium-chromedriver,Java,Google Chrome,Selenium,Selenium Webdriver,Selenium Chromedriver,在selenium中访问下面的方法时获取“无此类会话”异常。我知道网上有很多相同的问题和不同的答案,但在我的案例中似乎没有一个得到解决。有什么帮助吗 Chrome驱动程序版本:-2.38 铬合金版本:-66.0.3359.117 例外消息是:- org.openqa.selenium.NoSuchSessionException: no such session (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b

在selenium中访问下面的方法时获取“无此类会话”异常。我知道网上有很多相同的问题和不同的答案,但在我的案例中似乎没有一个得到解决。有什么帮助吗

Chrome驱动程序版本:-2.38 铬合金版本:-66.0.3359.117

例外消息是:-

org.openqa.selenium.NoSuchSessionException: no such session
  (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.10240 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'XXYYXX', ip: 'XXYYXX', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.38.552522 (437e6fbedfa876..., userDataDir: C:\Users\XXYYXX\AppData\L...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 66.0.3359.117, webStorageEnabled: true}
Session ID: 6db82d5d19891c00f783fd9b7cebd234
*** Element info: {Using=xpath, value=html/body/div[1]/div/div/div[2]/div/div[2]/div/div/p}
    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.ErrorHandler.createThrowable(ErrorHandler.java:214)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
    at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
    at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
    at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
    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:545)
    at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:346)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementsByXPath(RemoteWebDriver.java:425)
    at org.openqa.selenium.By$ByXPath.findElements(By.java:356)
    at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:307)
    at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:895)
    at org.openqa.selenium.support.ui.ExpectedConditions.access$000(ExpectedConditions.java:44)
    at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:206)
    at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:202)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:248)
    at UserInterfaceTesting.LoginValidator.validation(LoginValidator.java:31)
    at HybridFrameWork.test1.validation_of_server_response_at_something_page(test1.java:41)
    at ?.And Validation of server response at "Login" Page(Userlogin.feature:14)
我的节目:-

 else if (CommonObjRepository.getMessage().contentEquals("Login")) {


// This is where exception is being thrown //
            String Message = wait
                    .until(ExpectedConditions
                            .visibilityOfElementLocated(By.xpath("html/body/div[1]/div/div/div[2]/div/div[2]/div/div/p")))
                    .getText();

            assertEquals(ReadProperties.GetConstant("XXTTX"), Message);
            CommonObjRepository.getLog().info("***** XXXYYYZZZ *****");

        }
此错误消息

org.openqa.selenium.NoSuchSessionException: no such session
…表示chromedriver=2.38无法启动与WebClient(即Chrome浏览器)的活动会话

您的主要问题是所使用的二进制文件之间的版本兼容性,如下所示:

  • 尽管您使用的是最新的Selenium客户端版本3.11.0、Chrome驱动程序版本2.38和Chrome版本v66.0
  • 您的JDK版本是1.8.0_144,非常古老

解决方案
  • 将JDK升级到最新级别
  • 通过IDE清理项目工作区,并仅使用所需的依赖项重建项目
  • 如果您的基本Web客户端版本太旧,请卸载它并安装最新的GA和Web客户端发布版本
  • 重新启动系统
  • 执行
    @测试