"Exception in thread " 核问题后的主要" org.openqa.selenium.WebDriverException: invalid argument: can't ki



我有一个Selenium/Java程序,它运行,睡眠15分钟,然后再次运行(所有这些都来自Java,我没有使用cron或类似的程序。换句话说,我的程序总是保持打开状态。这只是一个破解。(

我运行此程序的计算机出现了短暂的网络问题,之后生成了以下堆栈跟踪

1604945147412   Marionette  INFO    Stopped listening on port 49990
1604946047821   mozrunner::runner   INFO    Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-foreground" "-no-remote" "-profile" "/var/folders/21/htmxfgcx7v14bbt2nr6v7ms40000gn/T/rust_mozprofile.1KxcETWwVjqE"
Exception in thread "main" org.openqa.selenium.WebDriverException: invalid argument: can't kill an exited process
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: '15.local', ip: '2002:c3bd:1b0a:0:9981:5f04:7c52:f5f7', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.4', java.version: '1.8.0_60'
Driver info: driver.version: FirefoxDriver
remote stacktrace: 
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:422)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
at kameo.KameoBid.main(MyApp.java:23)

第23行:

WebDriver driver = new FirefoxDriver();

当这种情况发生时,程序已经运行了20个小时(也就是说,它运行了10秒,然后是Thread.sleep(1000*60*15),然后是循环while (true)(。换句话说,它运行良好且稳定。

我看到过其他几个问题也有同样的错误消息,但在这些情况下,问题似乎是geckodriver和Firefox之间的不兼容,并且问题在第一次运行时立即出现(我在15分钟睡眠前执行了driver.close();(。

一个";未使用的";当我发现这个问题时,Firefox一直处于打开状态。不知道这是否重要。

有什么想法吗?

此错误消息。。。

Exception in thread "main" org.openqa.selenium.WebDriverException: invalid argument: can't kill an exited process
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: '15.local', ip: '2002:c3bd:1b0a:0:9981:5f04:7c52:f5f7', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.4', java.version: '1.8.0_60'
Driver info: driver.version: FirefoxDriver
remote stacktrace: 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

意味着GeckoDriver无法启动/生成新的浏览上下文,即Firefox浏览器会话。

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

  • 尽管您的SeleniumClient版本是最新的版本,即v3.141.59
  • 您的JDK版本1.8.0_60,它非常古老

因此,JDK v8u60Selenium Client v3.141.59之间存在明显的不匹配。


解决方案

确保:

  • JDK升级到当前级别JDK8u261
  • 进行系统重新启动
  • 以非root用户身份执行您的Test
  • 总是调用CCD_ 6方法中的CCD_;优雅地销毁WebDriverWeb客户端实例

最新更新