3

I am trying to launch chrome browser using RemoteWebDriver with the following code.

File file = new File("E:\\S\\chromedriver.exe"); //path to the chromedriver.exe so downloaded
//System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());

DesiredCapabilities capability = DesiredCapabilities.chrome();
capability.setBrowserName("chrome");
//capability.setVersion("38.0.2125.122 m");
WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:9898/"),capability);

I got 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.

I've checked that the port 9898 is open. I've added localhost in hosts in C:\Windows\System32\drivers\etc\hosts

Update: I can see two more exceptions.

Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:9515 [/127.0.0.1] failed: Connection refused.

Caused by: java.net.ConnectException: Connection refused:
orde
  • 5,233
  • 6
  • 31
  • 33
learningQA
  • 115
  • 1
  • 9

1 Answers1

0

I see that your chrome version fits to your chromedriver. I am not quiet sure which port should/can be used but you could try following options:

WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:9898"), capability);

or

WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"), capability);

Running tests local

You can use new ChromeDriver(capabilities);

Running tests remote

You need the selenium server to be installed. Can be installed on your local machine too. You can find it here: https://www.seleniumhq.org/download/ When installed and running you can connect to it using the RemoteWebDriver.

You can get more information in the selenium docs https://docs.seleniumhq.org/docs/03_webdriver.jsp#running-standalone-selenium-server-for-use-with-remotedrivers

AndiCover
  • 1,724
  • 3
  • 17
  • 38