【问题标题】:Selenium 3.0.1 crashes FireFox 51.0.1 during driver.quit() @ Win 7 Home Premium & GeckoDriver 0.13.0Selenium 3.0.1 在 driver.quit() @ Win 7 Home Premium & GeckoDriver 0.13.0 期间使 FireFox 51.0.1 崩溃
【发布时间】:2017-06-18 17:59:12
【问题描述】:

Win 7 和 FireFox 以德语运行。
Win 7 已安装所有可用更新。

32 位和 64 位 GeckoDriver 相同! (我的 Win 7 是 64 位;我的 FireFox 是 32 位)。

GeckoDriver 0.14 也是如此。

这只是我电脑的问题吗?

driver.quit() 在我的 InternetExplorer 上运行没有问题。

package JS_JFrame1;                                       

import org.openqa.selenium.WebDriver;                     
import org.openqa.selenium.firefox.FirefoxDriver;        

public class SeleniumFireFoxMinimal1 {  



public static void main(String[] args) throws InterruptedException {

    System.setProperty("webdriver.gecko.driver", "e:\\geckodriver.exe");

    WebDriver driver = new FirefoxDriver();                 

    driver.get("http://www.toolsqa.com");                    

    Thread.sleep(5000);                                   

    driver.quit();                                        

}                                                            

}                                                                    

像这样的其他 selenium 命令运行良好:

    element = driver.findElement(By.id("sinp"));              

    System.out.println( "Element found!");                   

    element.clear();                                                

    element.sendKeys("black");                                      

    element.submit();                                                       

Eclipse 控制台输出:

1485978825934 geckodriver INFO 在 127.0.0.1:21352 2 月 1 日收听, 2017 年 8:53:46 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFORMATION:尝试双语会话,假设 Postel 定律在远端成立 1485978826606 mozprofile::profile INFO 使用配置文件路径 C:\Users\xxxxxxx\AppData\Local\Temp\rust_mozprofile.qNYZq4KKbeGl 1485978826606 geckodriver::marionette INFO 启动浏览器 C:\Program 文件 (x86)\Mozilla Firefox\firefox.exe 1485978826637 geckodriver::marionette INFO 连接到 Marionette on localhost:51926 1485978828021 Marionette INFO 监听端口 51926 2017 年 2 月 1 日晚上 8:53:52 org.openqa.selenium.remote.ProtocolHandshake createSession 信息:检测到的方言:W3C JavaScript 警告: https://www.youtube.com/yts/jsbin/player-de_DE-vflWB2cvt/base.js,线 664:错误:WebGL:getParameter:参数:无效枚举值 [子 4416] ###!!!中止:在通道错误时中止。:文件 c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, 第 2056 行 2017 年 2 月 1 日 8:54:07 PM org.openqa.selenium.os.UnixProcess 销毁 SCHWERWIEGEND:无法使用 PID 4608 终止进程

【问题讨论】:

  • 你试过重启电脑后运行吗?
  • 是的,Jeroen,3 天 20 次。
  • 改用 Firefox 50。它应该工作

标签: selenium firefox geckodriver


【解决方案1】:

browser.tabs.remote.autostart.2 设置为false

FirefoxOptions options = new FirefoxOptions();
options.BrowserExecutableLocation = Settings.Default.FirefoxBinary;

>>>> profile.SetPreference("browser.tabs.remote.autostart.2", false);
FirefoxProfile profile = new FirefoxProfile();
....
options.Profile = profile;
driverSet.Driver = new FirefoxDriver(options);

【讨论】:

  • 我在 about:config 中有两个这样的自动启动条目——一个带有扩展名 2,一个没有扩展名。我现在将两个条目都设置为 false,但它没有任何改变。 FireFox 仍然崩溃(当然我重新启动了 FireFox)。其他 6 行代码呢?我的 Java-Selenium-snip 中是否也需要它们?谢谢。
【解决方案2】:

这个问题与firefox从firefox版本> = 50开始使用多进程环境有关,似乎selenium无法处理它。

添加以下行应该可以解决此问题:

FirefoxProfile ffProfile = new FirefoxProfile();
ffProfile.setPreference("browser.tabs.remote.autostart.2", false);
WebDriver driver = new FirefoxDriver(newFirefoxOptions().setProfile(ffProfile));

【讨论】:

    【解决方案3】:

    这是一个已知的 Firefox/geckodriver 退出驱动程序的问题,请参阅here 了解更多详细信息。

    它出现在一些FF版本中,有人说它是固定的,有人说它不是。我找不到更好的解决方案,所以我打开了“旧”Firefoxdriver 和 FF v47.0.2,它工作正常。

    【讨论】:

      【解决方案4】:

      我找到了解决方法。我的代码在 C# 中

      Utility.Instance.KillProcess("firefox");
      System.Windows.Forms.SendKeys.SendWait("{ESC}");
      Utility.Instance.KillProcess("geckodriverserver");
      

      希望对你有所帮助。

      【讨论】:

        猜你喜欢
        • 2017-07-29
        • 1970-01-01
        • 2018-10-22
        • 1970-01-01
        • 2017-04-04
        • 2017-07-28
        • 2020-06-04
        • 1970-01-01
        相关资源
        最近更新 更多