I use Firefox version 54.0.1 (64-bit), Geckodriver v0.17.0-win64 and Selenium 3.4.0 but when I run my scenarios Firefox opens and after one second closes. So, my scenarios ignored. I used different versions of Firefox, Geckodriver and Selenium. But not helped This is my code:
private static WebDriver createConfiguredDriver() {
final String driverName = TestData.getBrowser(); //BrowserType.FIREFOX
final boolean remote = TestData.isRemoteMode(); //"webdriver.isremote";
DesiredCapabilities desiredCapabilites = new DesiredCapabilities(driverName, "", Platform.ANY);
desiredCapabilites.setCapability("marionette", false);
if (remote) {
final String host = TestData.getBrowserHost();
final int port = TestData.getBrowserPort();
logger.info("Remote browser host: " + host);
logger.info("Remote browser port: " + port);
try {
URL remoteAddress = new URL("http", host, port, "/wd/hub");
return new RemoteWebDriver(remoteAddress, desiredCapabilites);
} catch (MalformedURLException mue) {
throw new IllegalArgumentException("Failed to create remote URL using host: " + host, mue);
}
}
else if (BrowserType.FIREFOX.equalsIgnoreCase(driverName)) {
System.setProperty("webdriver.gecko.driver",
"src\\main\\resources\\geckodriver\\geckodriver.exe");
logger.info("Using local FireFox WebDriver.");
// desiredCapabilites.setCapability("firefox_binary", "C:\\Program Files\\Mozilla Firefox\\firefox.exe");
return new FirefoxDriver(desiredCapabilites);
This is my pom.xml:
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium.fluent</groupId>
<artifactId>fluent-selenium</artifactId>
<version>1.14.5</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<scope>test</scope>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.0.11</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<profile>
<id>firefox</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<webdriver.driver>firefox</webdriver.driver>
</properties>
</profile>
<profile>
<id>remote</id>
<properties>
<webdriver.isremote>true</webdriver.isremote>
<webdriver.host>vwbnode01</webdriver.host>
<webdriver.port>4444</webdriver.port>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<skip>false</skip>
<forkCount>1</forkCount>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.15</version>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/Test*.java</include>
<include>**/*Steps.java</include>
<include>**/*TestRunner.java</include>
</includes>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.2</version>
</plugin>
</plugins>
</build>
My console:
rg.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'WS00MU016', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '9.0.1' Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:658) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:191) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:108) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:137) at com.dods.ui.mpp.tests.runner.CucumberTestRunner.createConfiguredDriver(CucumberTestRunner.java:60) at com.dods.ui.mpp.tests.runner.CucumberTestRunner.init(CucumberTestRunner.java:84) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at cucumber.api.junit.Cucumber.run(Cucumber.java:100) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Caused by: java.lang.NullPointerException at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192) at org.openqa.selenium.firefox.XpiDriverService.start(XpiDriverService.java:94) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637) ... 24 more
createConfiguredDriver
and how you're disposing the driver. Have you stepped through the code to see exactly when the browser closes? Could it be possible you're accidentally disposing it before you use it? - mrfreester