org.openqa.selenium.firefox.NotConnectedException启动火狐
问题描述:
当我收到此错误信息,同时试图发起Firefox
浏览器:org.openqa.selenium.firefox.NotConnectedException启动火狐
org.openqa.selenium.firefox.NotConnectedException:无法连接 在45000 ms后在端口7055上托管127.0.0.1。 Firefox的控制台输出: 的 “:[],” hasEmbeddedWebExtension“:假}
我使用selenium 3.3.1
和firefox 52
答
您需要使用Firefox的GeckoDriver。这对旧版本的Selenium 2.x并不需要,但是它需要Selenium 3.x
如果您的FF浏览器是32位或64位,则需要下载GeckoDriver。您还需要提供GeckoDriver和FirefoxBirnary路径。
System.setProperty("webdriver.gecko.driver","D:\\Firefox\\geckodriver.exe");
FirefoxOptions options = new FirefoxOptions();
options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //This is the location where you have installed Firefox on your machine
FirefoxDriver driver = new FirefoxDriver(options);
driver.get("http://www.google.com");
您可以检查此链接了解更多信息 - - 你可以用它来启动浏览器的代码示例http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/
显示浏览器的配置代码 –