I need to create simple autotest using FirefoxDriver with Maven.
excerpt from pom.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
test case:
@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");
}
And after running test executing command
mvn -test
I receive the following exception:
org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe) on port 7055; process output follows: egistering shutdown blocker for LightweightThemeManager
Mozilla Firefox version: 49.0.1
(it should be compatible with Selenium Webdriver). "hosts" file is empty. Windows firewall is disabled.
Do you have any ideas, how could I fix the problem?
It looks like incompatibility issue between Selenium2
and Mozilla Firefox version: 49.0.1
.
Actually Mozilla
has launched executable geckodriver
to support latest firefox >= v47
just like other driver executable with selenium.
You need to download latest geckodriver executable first , extract downloaded zip file into your system at any location and set this executable path with executable itself into System
properly with variable webdriver.gecko.driver
.
Now run selenium script to launch Mozilla Firefox
using marionette
as below :-
System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe");
//Now you can Initialize marionette driver to launch firefox
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new MarionetteDriver(capabilities); //for selenium 3 use new FirefoxDriver(capabilities);
Note :- If Mozilla Firefox
installed at default location into your system, no need to provide explicitly binary path into selenium script, selenium would itself find it from default location.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.