2017-04-20 56 views
1

当我收到此错误信息,同时试图发起Firefox浏览器:org.openqa.selenium.firefox.NotConnectedException启动火狐

org.openqa.selenium.firefox.NotConnectedException:无法连接 在45000 ms后在端口7055上托管127.0.0.1。 Firefox的控制台输出: 的 “:[],” hasEmbeddedWebExtension“:假}

我使用selenium 3.3.1firefox 52

+0

显示浏览器的配置代码 –

回答

0

我会检查你的驱动程序如geckodriver是与Firefox的安装版本兼容。

这里有一个类似的问题,可以帮助你: Unable to connect to Firefox

+0

我需要使用GeckoDriver? – Parveen

+0

您需要使用驱动程序来将硒连接到浏览器,在Firefox中,这个名为geckodriver的驱动程序可以在[https://github.com/mozilla/geckodriver/releases]中获得。确保你使用硒3.3.1以及使用壁虎驱动时。 – Jpc133

+0

我正在使用壁虎版本 - v0.15 – Parveen

0

试图通过把路径壁虎驱动 System.s etProperty(“webdriver.gecko.driver”,“< geckodriver path>”)

+0

我使用硒版本3.3.1 – Parveen

+0

System.setProperty( “webdriver.gecko.driver”,“C:\\ \\壁虎geckodriver.exe) \t \t webdriver的驱动程序=新FirefoxDriver(); – Parveen

+0

仍然存在是** NotConnectedException ** – xyz

0

您需要使用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/

+0

谢谢@Anish Pillai。我尝试了以下步骤并设置了壁虎,但现在仍然面临着不幸的问题:org.openqa.selenium.firefox。NotConnectedException:无法在45000 ms后连接到端口7055上的主机127.0.0.1。 Firefox控制台输出: webNavigation“,”webRequest“]}} – Parveen

+0

而且当firefox浏览器启动时,有两个选项卡打开,第二个选项卡上可以看到'Skype'网站的启动。 – Parveen