无法在端口7055上连接到主机127.0.0.1

use*_*258 7 webdriver

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

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

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

45000 ms后无法在端口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;
    }
}
Run Code Online (Sandbox Code Playgroud)

}

nil*_*esh 8

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

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