当我尝试在java中使用selenium webdriver运行我的第一个测试用例时,我得到以下异常。有人可以帮我解决问题.....
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 48523
Only local connections are allowed.
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Mar 29, 2018 7:34:16 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'NIL-MKODAGA-D13', ip: '172.16.20.242', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '9.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome= {chromedriverVersion=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f), userDataDir=C:\Users\mkodagan\AppData\Local\Temp\scoped_dir4652_10811}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=65.0.3325.181, platform=WIN8_1, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: 1a39885769cc96406e2f2732c361c049
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:272)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:96)
at com.ham.scripts.ClickOnAllLinks.main(ClickOnAllLinks.java:44)
答案 0 :(得分:6)
错误说明了一切:
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.3.9600 x86_64)
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'NIL-MKODAGA-D13', ip: '172.16.20.242', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '9.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
错误明确表示 Selenium客户端和 ChromeDriver 未被检测到,如下所示:
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
Driver info: org.openqa.selenium.chrome.ChromeDriver
您的主要问题是您使用的二进制文件之间的版本兼容性,如下所示:
支持 Chrome v60-62
支持 Chrome v64-66
因此, Selenium Client v3.4.0 , ChromeDriver 版本( v2.33 )与之间存在明显的不匹配Chrome浏览器版本( v65.0 )
@Test
。答案 1 :(得分:1)
如@DebanjanB所述,问题在于chromedriver版本。从日志中你可以看到它使用chromedriver = 2.33.506120,这有点旧。检查" https://sites.google.com/a/chromium.org/chromedriver/downloads"。
的最新版本我也遇到了同样的问题,通过更新Chrome驱动程序可以解决问题。 您可以使用以下方法来解决它。
import itertools
lst = [True, True, True, True, False, False, True, False, True, True, False]
x = min(sum(1 for _ in l) for n, l in itertools.groupby(lst))
>>> x
1
将此chromedriver替换为最新的chromedriver并运行您的代码。它应该工作正常。
注意:该位置可能是特定于操作系统的,因此请搜索chromedriver确切位置。