1

I'm using Selenium Standalone Server 3.141.59 https://www.seleniumhq.org/download

In my code, when a WebDriver is created the Selenium server debugs something like: Starting ChromeDriver on port 28208

Is it possible to configure a range of ports (e.g., 28000-28100) that are allowed to be used by the Selenium server?

cnmuc
  • 6,025
  • 2
  • 24
  • 29

1 Answers1

1

Use below code to configure chrome to run on other then default port.

int desiredPortNo = 22300;
ChromeDriverService service = new ChromeDriverService.Builder().usingDriverExecutable(new File("chrome_driver_path")).usingPort(desiredPortNo).build();
WebDriver driver = new ChromeDriver(service);

Update

To use with RemoteWebDriver :

int desiredPortNo = 22300;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("...", true);

ChromeDriverService service = new ChromeDriverService.Builder()
            .usingDriverExecutable(new File("driver_path")).usingPort(desiredPortNo)
            .build();
service.start();
WebDriver driver = new RemoteWebDriver(service.getUrl(),capabilities);
driver.get("site_url");
NarendraR
  • 7,577
  • 10
  • 44
  • 82
  • As I'm using a Selenium Server, I'm using a RemoteWebDriver. But I don't see a way to pass the ChromeDriverService instance to a RemoteWebDriver instance. Is there a way? – cnmuc Mar 28 '19 at 11:46
  • 1
    Hey Checkout the answer here https://stackoverflow.com/questions/47671884/how-to-merge-chrome-driver-service-with-desired-capabilities-for-headless-using – NarendraR Mar 28 '19 at 12:09
  • @cnmuc, Updated the answer, have a look – NarendraR Mar 28 '19 at 12:16
  • Thx, but I don't get the idea of it. As the Selenium server is running on a remote machine the client should not know about the path to the executable. That's why I'm using a remote driver. The URL of the remote server may differ in my case (it's passed in via Jenkins), so the path on the remote machine may differ too. – cnmuc Mar 28 '19 at 15:06
  • Please update your questions with more details and data you are using. So someone can help you out in better way – NarendraR Mar 28 '19 at 16:20