今天学习自动化测试工具selenium,在idea中启动后出现如下问题:
警告: The chromedriver version (123.0.6312.122) detected in PATH at C:\Program Files\Python310\chromedriver.exe might not be compatible with the detected chrome version (127.0.6533.73); currently, chromedriver 127.0.6533.72 is recommended for chrome 127.*, so it is advised to delete the driver in PATH and retry
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: This version of ChromeDriver only supports Chrome version 123
Current browser version is 127.0.6533.73 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe
Host info: host: 'DESKTOP-O0IJFIJ', ip: '192.168.163.1'
Build info: version: '4.22.0', revision: 'c5f3146703*'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.7'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--remote-allow-origins=*], binary: C:\Program Files\Google\Chr..., extensions: []}}]}]
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:114)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:61)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:162)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:232)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:161)
at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:114)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:72)
at com.swc.FirstScript.main(FirstScript.java:18)
发现了一个问题,我的jdk里的ChromeDiver只能够支持谷歌123版本,然后查看我谷歌的版本,好家伙,谷歌自动更新到127版本了,如图:
解决方案:
1、去下载对应的谷歌驱动版本,地址:Chrome for Testing availability (googlechromelabs.github.io)
2、下载完后将里面的chromedriver.exe复制到存放jdk的bin目录下:
结果:
成功!!!
版权归原作者 swclovelearning 所有, 如有侵权,请联系我们删除。