【问题标题】:Unable to connect to host 127.0.0.1 issue in selenium webdriver无法连接到 selenium webdriver 中的主机 127.0.0.1 问题
【发布时间】:2016-12-22 11:49:39
【问题描述】:

我正在尝试运行以下示例 sn-p

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 毫秒后无法连接到端口 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。

谁能帮我解决这个问题。

【问题讨论】:

标签: java android selenium selenium-webdriver


【解决方案1】:

韦斯·杨是对的。 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 和 selenium 3 使用旧的 firefox 驱动程序(以扩展形式)。有一个属性告诉我们要使用旧版驱动程序(扩展形式的旧 firefox 驱动程序)或新驱动程序(gecko 驱动程序)。这必须在功能中设置。

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

其他语言类似

【解决方案2】:

FireFox 48 带来了一些不能很好地与 webdriver 配合使用的更改。您需要将 Firefox 切换到 Marionette。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-16
    • 1970-01-01
    • 2011-05-09
    • 1970-01-01
    • 2012-09-17
    • 1970-01-01
    • 1970-01-01
    • 2020-02-12
    相关资源
    最近更新 更多