My selenium code does not run. Keeps throwing me the following error:
Exception in thread "main" org.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: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'SLAP129', ip: '192.168.4.218', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_74'
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.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:191)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:108)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:104)
at PractiseSession1.OpenBrowser(PractiseSession1.java:35)
at PractiseSession1.main(PractiseSession1.java:16)
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)
... 8 more
FIREFOX VERSION: 53.0.3 (32 Bit) SELENIUM VERSION: selenium-java-3.4.0 I am using Eclipse Luna and my machine is Windows 7 (64 bit). I have read all the the help queries but could not find solution. Here is my Java code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class PractiseSession1
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
WebDriver driver = null;
String URL="http://www.google.com";
//System.out.println("Application title is =============");
PractiseSession1 ade= new PractiseSession1();
ade.OpenBrowser(driver);
ade.GetPage(URL, driver);
ade.quitbrowser(driver);
}
private void quitbrowser(WebDriver driver)
{
driver.quit();
}
private void GetPage(String URL, WebDriver driver)
{
driver.get(URL);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
private void OpenBrowser(WebDriver driver)
{
System.setProperty("webdriver.firefox.marionette", "<Geckodriver
path>geckodriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
driver= new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
}
You should replace
driver = new FirefoxDriver();
with
driver = new FirefoxDriver(capabilities);
so that you run the test with the desired capabilities.
Only issue with that is that it may not work with 3.4.0 as the default timeout value was reduce and may be too short now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With