【问题标题】:Unable to connect to host 127.0.0.1 on port 7055无法在端口 7055 上连接到主机 127.0.0.1
【发布时间】:2012-04-04 15:05:59
【问题描述】:

我是 webdriver 的新手,需要一些帮助..

我在 Windows XP 上使用 Selenium 2.2.0 和 FF v7.0.1

我已经成功地在 IE 中录制和播放了一个 java 脚本,但是每当我尝试在 FF 中执行相同的脚本时,我都会收到以下错误消息:

45000 毫秒后无法连接到端口 7055 上的主机 127.0.0.1

我在许多地方读到,如果我将 Firefox 版本降级到 3.6 脚本将正常工作,但我并不热衷于降级。有人可以告诉我我做错了什么吗?

package hisScripts;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;


public class WebdriverTest_1 {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
    driver = new FirefoxDriver();
    //driver=new InternetExplorerDriver();
    baseUrl = "https://**********/";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

@Test
public void testUntitled() throws Exception {
    driver.get(baseUrl + "/");
    driver.findElement(By.xpath("//a[contains(text(),'my profile')]")).click();
    driver.findElement(By.xpath("//a[contains(text(),'about the service')]")).click();
    driver.findElement(By.xpath("//a[contains(text(),'contact us')]")).click();
    driver.findElement(By.xpath("//a[contains(text(),'help')]")).click();
    driver.findElement(By.xpath("//a[contains(text(),'home')]")).click();
    driver.findElement(By.xpath("//a[contains(text(),'logout')]")).click();

}

@After
public void tearDown() throws Exception {
    driver.quit();
    String verificationErrorString = verificationErrors.toString();
    if (!"".equals(verificationErrorString)) {
        fail(verificationErrorString);
    }
}

private boolean isElementPresent(By by) {
    try {
        driver.findElement(by);
        return true;
    } catch (NoSuchElementException e) {
        return false;
    }
}

}

【问题讨论】:

  • 代码没问题。升级呢?从 FF7 到 FF9 或 10? Selenium 不能很好地与 FF11 配合使用(到目前为止),但 FF9 工作正常!
  • @slanec - 我已经升级到 FFv10.0.2 但仍然没有乐趣 - 我还有什么办法可以解决这个问题吗?

标签: webdriver


【解决方案1】:

您使用的 selenium 版本非常旧。我认为 v2.2 不支持 firefox 10。最新的是 2.20。

查看更改日志here。从这里的注释来看,从 v2.19.0 开始支持 firefox 10 中的本机事件,这意味着您需要 2.19 或更高版本才能支持 firefox 10。

【讨论】:

  • 感谢您指出这一点。事实证明这是一个愚蠢的错误,我认为 selenium 2.2.0 与 Selenium 2.20.0 相同。为了纠正这个问题,我从seleniumhq.org/download 下载了最新的“服务器”和“客户端驱动程序”(在我的例子中是 Java)并猜猜它的效果如何:)
  • 在 Rails 环境中,这可能意味着升级用于运行远程服务器的 selenium-server jar 以及升级服务器使用的 gem。我有后者是最新的,但忘记了前者也需要升级。
  • 我在 2.24.X 版本中遇到了类似的问题。所以我改为2.25.0。谢谢。
  • 对于 Firefox 29.0 我更改为 selenium 驱动程序 2.39.0
【解决方案2】:

此问题是由于火狐版本和selenium jar文件版本的兼容性。使用最新的selenium jar文件可以解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-05
    • 2014-11-02
    • 2013-04-27
    • 2016-11-06
    • 1970-01-01
    • 2012-09-17
    • 2017-06-07
    • 1970-01-01
    相关资源
    最近更新 更多