首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Selenium 3.12在driver.quit() @ FireFox 60 /Win7家庭高级版/Java10.0.1/ GeckoDriver 0.20.1上显示错误

Selenium 3.12在driver.quit() @ FireFox 60 /Win7家庭高级版/Java10.0.1/ GeckoDriver 0.20.1上显示错误
EN

Stack Overflow用户
提问于 2018-05-12 19:39:30
回答 1查看 1.6K关注 0票数 3

我的电脑:

Win 7/ 64位-已安装所有更新

FireFox 60.0 / 64位

Java 10.0.1

Selenium 3.12

Geckodriver 0.20.1 / 64位

Eclipse 4.7.3a

JAVA源码:

代码语言:javascript
复制
public class SeleniumFireFoxMinimal1 {                                                             
    public static void main(String[] args) throws InterruptedException {                           
        System.setProperty("webdriver.gecko.driver", "e:\\geckodriverwrapper.bat");                       
        WebDriver driver = new FirefoxDriver();                 
        driver.get("http://www.toolsqa.com");                                                      
        driver.quit();                                                                             
    }                                                                                              
}

geckodriverwrapper.bat:

代码语言:javascript
复制
@ECHO OFF  
ECHO Starting geckodriver: %0 %*  
E:\geckodriver.exe --log trace %* > NUL 2>&1  

Eclipse控制台输出:

代码语言:javascript
复制
Starting geckodriver: E:\geckodriverwrapper.bat --port=27751 -b "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
Mai 12, 2018 1:14:15 VORM. org.openqa.selenium.remote.ProtocolHandshake createSession
INFORMATION: Detected dialect: W3C

在Firefox窗口关闭15秒后,将显示以下行:

代码语言:javascript
复制
Mai 12, 2018 1:14:37 VORM. org.openqa.selenium.os.OsProcess destroy
INFORMATION: Unable to drain process streams. Ignoring but the exception being swallowed follows.
org.apache.commons.exec.ExecuteException: The stop timeout of 2000 ms was exceeded (Exit value: -559038737)
    at org.apache.commons.exec.PumpStreamHandler.stopThread(PumpStreamHandler.java:295)
    at org.apache.commons.exec.PumpStreamHandler.stop(PumpStreamHandler.java:181)
    at org.openqa.selenium.os.OsProcess.destroy(OsProcess.java:135)
    at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:153)
    at org.openqa.selenium.remote.service.DriverService.stop(DriverService.java:222)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:95)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
    at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:443)
    at at.xxxxxxx.work.SeleniumFireFoxMinimal1.main(SeleniumFireFoxMinimal1.java:40)
Mai 12, 2018 1:14:37 VORM. org.openqa.selenium.os.OsProcess destroy
SCHWERWIEGEND: Unable to kill process Process[pid=4320, exitValue=1]

其他类似这样的Selenium命令可以很好地工作:

代码语言:javascript
复制
element = driver.findElement(By.id("sinp"));              
element.clear();                                                
element.sendKeys("black");                                      
element.submit();                                                                                                                                                           

这只是我电脑上的问题吗?

driver.quit()正在InternetExplorer上工作,没有任何问题。

也许我们必须重新讨论这个问题?:

https://github.com/SeleniumHQ/selenium/issues/4678

https://github.com/mozilla/geckodriver/issues/954

https://bugzilla.mozilla.org/show_bug.cgi?id=1401109

Now (2018年5月15日)我也在这里发布了:

https://github.com/mozilla/geckodriver/issues/1272

EN

回答 1

Stack Overflow用户

发布于 2018-10-09 03:48:10

我没有一个干净的解决方案,但有一个变通办法:我将driver.quit()改为driver.close()。这通常用于关闭窗口。但如果这是最后一个窗口,它就能正常工作。测试:

  • geckodriver 0.18.0
  • Java 1.8.0_65
  • Raspbian GNU/Linux 8 GNU/Linux 52.9.0
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50305819

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档