无法连接到selenium webdriver中的主机127.0.0.1问题

时间:2016-08-16 07:43:24

标签: java android selenium selenium-webdriver

我试图运行以下示例代码段

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Test
{
public static void main(String[] args)
{
     WebDriver driver = new FirefoxDriver();    
      driver.get("http://www.google.com");

    //System.out.println("My new program");

}
}

运行此代码时,出现以下错误。

45000 ms后无法在端口7055上连接到主机127.0.0.1。 Firefox控制台输出:

e6fd}","syncGUID":"zxeywUS-QRBG","location":"app-global","version":"48.0","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1469556455000,"updateDate":1469556455000,"applyBackgroundUpdates":1,"skinnable":true,"size":21899,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"48.0","maxVersion":"48.0"}],"targetPlatforms":[],"seen":true}
1471332673510   addons.xpi  DEBUG   getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}

Firfox版本是48.0 在eclipse中添加的jar是selenium-java-2.53.0,selenium-java-2.53.0-srcs。

有谁可以帮我解决这个问题。

2 个答案:

答案 0 :(得分:1)

FireFox 48带来了一些与webdriver不能很好搭配的变化。你需要将firefox切换到Marionette。

此处的说明:https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette

答案 1 :(得分:0)

Wes Young是对的。 Firefox从版本48开始改变了行为。 你需要使用selenium 3和firefox提供的gecko驱动程序。

小解释: 在Selenium 3之前,FirefoxDriver曾经是Firefox Extension的形式,当我们使用firefox驱动程序时,它已经安装了。 但是从版本48开始,Firefox改变了扩展程序在firefox中的行为,基本上每个扩展都必须由firefox签名,并且驱动程序扩展不符合这一要求。 所以Firefox负责开发firefox的独立驱动程序,就像我们在chrome中一样。 基本上你必须下载gecko驱动程序放在某处并在webdriver.gecko.driver系统变量中配置路径然后使用它。它与我们现在使用chromedriver的方式几乎相同。

PS:我们仍然可以使用旧的firefox驱动程序(扩展形式)使用以前版本的firefox和selenium 3。有一个属性告诉我们要使用旧驱动程序(扩展形式的旧firefox驱动程序)或新驱动程序(gecko驱动程序)。这必须在功能中设置。

caps["marionette"] = True/False in python

与其他语言相似

相关问题