繁体   English   中英

Selenium WebDriver + Firefox哪个版本可以正常工作?

[英]Selenium WebDriver + Firefox which version works fine?

我正在编写一个自动化脚本来测试网站登录。 通过Firefox IDE,我已经编写了TestCase步骤,它执行得很好。 我将测试用例导出为与jUnit 4兼容的Java代码。

当我尝试通过Eclipse(使用firefox浏览器)运行Java代码时,它会打开Mozilla主页或空白页或代理问题(如果我的计算机已连接到公司LAN)。

我使用的是Selenium 2.44和Firefox版本44。另外,我在一些网站上读到有关Firefox与Selenium Web驱动程序兼容版本的信息。 我对此很困惑。

请让我知道首选哪个版本的Selenium Web驱动程序,Firefox和Java。

在下面添加我的Java代码

public class Firefox {
private WebDriver driver;
private String PROXY = "proxy address:port";
private String baseUrl;
private boolean acceptNextAlert = true;
@Before
public void setUp() throws Exception {
// Code for setting up Firefox proxy
Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
.setFtpProxy(PROXY)
.setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
driver = new FirefoxDriver(cap);
baseUrl = "url";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testFirefox() throws Exception {
driver.get(baseUrl);
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { 
if ("".equals(driver.findElement(By.id("userId")).getText())) break; 
}
catch (Exception e) {}
Thread.sleep(1000);
}
driver.findElement(By.id("userId")).sendKeys("user name");
driver.findElement(By.id("pwd")).sendKeys("password");
driver.findElement(By.id("sign-in")).click();
}
}

我发现并正在使用的最新稳定兼容配置是Selenium Webdriver 2.48.2和Firefox 41.0.2

https://www.mozilla.org/zh-CN/firefox/organizations/all/下载Firefox ESR

Firefox的稳定版本浏览器与Webdriver 2.48.2兼容。 Selenium WebDriver 2.48.2不适用于FF 44。

对于所有非本机事件,例如JavascriptExecutor事件,最新的Firefox始终可以与最新版本的Selenium(2.x版本)一起使用,但是也存在一些本机事件(例如driver.navigate.to()和driver.click( )只能在最近的本机受支持的Firefox版本( 31.6.0 ESR)下运行 ,但更高版本的ESR可能可以运行,但我在任何地方都没有读过。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM