我需要使用带有Maven的FirefoxDriver创建简单的自动测试。从pom.xml中如何使用Maven在Firefox中运行Selenium WebDriver测试用例?
摘录:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
测试用例:
@BeforeTest
public void StartBrowser_NavURL() {
capability = DesiredCapabilities.firefox();
capability.setCapability("platform", Platform.ANY);
capability.setCapability("binary", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
driver = new FirefoxDriver(capability);
driver.manage().window().maximize();
}
@AfterTest
public void CloseBrowser() {
driver.quit();
}
@Test
public void testToCompareDoubles() {
driver.get("http://www.google.com");
}
并运行测试执行命令后
mvn -test
我收到以下异常:
org.openqa.selenium.WebDriverException:端口7055无法连接到二进制FirefoxBinary(C:\ Program Files(x86)\ Mozilla Firefox \ firefox.exe);过程输出如下:轻量级关机拦截器LightweightThemeManager
Mozilla Firefox version: 49.0.1
(它应该与Selenium Webdriver兼容)。 “hosts”文件是空的。 Windows防火墙被禁用。
你有什么想法,我该如何解决这个问题?