我是一个新手,需要关于webdriver的帮助。
我正在使用Selenium 2.2.0和Windows XP上的FF v7.0.1。
我已经成功地在IE中记录并回放了一个Java脚本,但是每当我尝试在FF中执行相同的脚本时,我会收到以下错误消息:
无法在45000毫秒后连接127.0.0.1上的7055端口的主机
我已经在许多地方读到过,如果将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;
}
}
}