出现未创建会话异常:未创建会话:此版本的ChromeDriver仅支持Chrome版本111错误与Selenium

db2dz4w8  于 2023-02-17  发布在  Go
关注(0)|答案(1)|浏览(231)

我确信我的测试工作正常。当我运行代码时,我在终端中得到了错误,如,

Scenario: User adds new quick work order to employee from website # src/test/java/Features/5NewQuickJobOrder.feature:12
Starting ChromeDriver 111.0.5563.19 (378a38865270d286695aeb86f190564911ef7bc2-refs/branch-heads/5563@{#251}) on port 4290
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
      org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 111
Current browser version is 110.0.5481.97 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-CONJ3EC', ip: '192.168.1.27', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '19.0.2'
Driver info: driver.version: ChromeDriver

最近Chrome更新自己,我的版本现在是110.0.5481.97。但不知何故,它尝试运行测试与版本111显示如下。我没有版本在我的计算机中,这样开始与111。

Scenario: User adds new quick work order to employee from website # src/test/java/Features/5NewQuickJobOrder.feature:12
Starting ChromeDriver 111.0.5563.19 (378a38865270d286695aeb86f190564911ef7bc2-refs/branch-heads/5563@{#251}) on port 40758
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

我不使用任何chromedriver exe在我的项目文件夹中,我直接使用安装程序和驱动程序intsance。

public static WebDriver initialize_Driver(String browser) {
        properties = ConfigReader.getProperties();

        if (browser.equals("Chrome")) {
            WebDriverManager.chromedriver().setup();
            driver = new ChromeDriver();

        }

@Before
    public void before() {
        String browser = Reporter.getCurrentTestResult().getTestContext().getCurrentXmlTest().getParameter("browser");
        properties = ConfigReader.initialize_Properties();
        driver = DriverCreater.initialize_Driver(browser);
    }

如果你能帮助我,我将非常高兴!

5f0d552i

5f0d552i1#

首先是溶液

要示例化ChromeDriver的特定浏览器版本,可以使用:

WebDriverManager.chromedriver().driverVersion("111.0.5563.19").setup();

详情

此错误消息...

org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 111

...表示由于ChromeDriver无法生成新的 * 浏览上下文 *(即google-chrome会话)而引发 * SessionNotCreatedException *。
您的主要问题是所使用的二进制文件版本之间的不兼容性,如下所示:

  • 您正在使用 * chrome = 110.0.5481.97 *
  • 但是您使用的是 * chromedriver = 111.0.5563.19 *
  • chromedriver=111.0的发行说明中明确提到了以下内容:

支持Chrome版本111
因此,* chromedriver = 111.0 * 和 * chrome = 110.0 * 之间存在明显的不匹配
溶液
确保:

相关问题