【问题标题】:Selenium 2.47 doesn't work with Firefox v31Selenium 2.47 不适用于 Firefox v31
【发布时间】:2015-08-16 00:28:23
【问题描述】:

我在 Firefox v31 中使用 selenium 2.47。通过这个简单的实现:

public void navigateToHomePage() throws Throwable {
    System.out.println("Navigate to Home");
    driver = new FirefoxDriver();
    driver.quit();
}

我收到了这个错误:

org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms
Build info: version: '2.47.0', revision: '0e4837e', time: '2015-07-29 22:49:49'
System info: host: 'ok-ThinkPad-SL500', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-24-generic', java.version: '1.7.0_79'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:99)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:90)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:276)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:223)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:212)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
    at cucumber.features.StepDefinitions.navigateToHomePage(StepDefinitions.java:24)
    at ✽.Given I navigate to the home site(/home/ok/workspace/CucumberPOC/src/cucumber/features/UserRegistry.feature:6)

不知道是什么??

【问题讨论】:

    标签: selenium selenium-webdriver selenium-firefoxdriver


    【解决方案1】:

    当 Firefox 尝试绑定到端口 7054 并失败时会发生此 SocketLock 错误,因为另一个实例已经锁定了该端口。

    一个直接的解决方案是确保在启动新驱动程序之前没有 Firefox 任务或进程在后台运行。将它们全部杀死,然后再次尝试启动。

    从长远来看,您可以通过创建新配置文件、更改端口首选项以避免锁定,然后使用该配置文件启动驱动程序来避免这些问题。一个简短的例子:

    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference(FirefoxProfile.PORT_PREFERENCE, 7046)
    driver = new FirefoxDriver(profile);
    

    不幸的是,当我在查找Java术语时,我发现这个功能在Java的驱动程序中被破坏了一次,然后是it was fixed,然后是it broke in a later update,所以即使你实现了我给你的解决方案,你仍然可能在 2.47 中得到这些错误。

    The fix was released in version 2.43.1,因此如果您不需要更新版本的其他问题/功能,您可以尝试回滚到可以成功设置端口首选项的位置。

    非必读:Some more technical details of the issue are in this pull request.

    【讨论】:

      猜你喜欢
      • 2015-02-03
      • 1970-01-01
      • 2016-11-25
      • 2016-12-06
      • 2016-12-12
      • 2017-03-05
      • 2017-03-19
      • 1970-01-01
      相关资源
      最近更新 更多