【发布时间】: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