manjit pandey
manjit pandey

Reputation: 1

Invalid port. Exiting...org.openqa.selenium.os.OsProcess checkForError using ChromeDriver and Chrome through Selenium

Source code:

package Labarary;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;


public class LAb {

    public static void main(String[] args) {
        System.out.println("chrome");
        System.setProperty("webdriver.chrome.driver","C:\\Users\\Manjit\\Downloads\\chromedriver_win32\\chromedriver.exe");
        // TODO Auto-generated method stub
        WebDriver driver=new ChromeDriver();
    }
}

Invalid port. Exiting... ??? ??, ???? ??:??:?? ???????

org.openqa.selenium.os.OsProcess checkForError SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start. Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z' System info: host: 'MANJIT-PC', ip: '192.168.1.19', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_171' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192) at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:130) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:181) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:168) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) at Labarary.LAb.main(LAb.java:20) Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:?????/status] to be available after ????? ms at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100) at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:187) ... 9 more Caused by: java.util.concurrent.TimeoutException at java.util.concurrent.FutureTask.get(Unknown Source) at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:148) at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75) ... 10 more

Upvotes: 0

Views: 1341

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193358

This error message...

Invalid port. Exiting... ??? ??, ???? ??:??:?? ???????
org.openqa.selenium.os.OsProcess checkForError

...implies that the OsProcess is unable to bind the ChromeDriver server process to the assigned free port within your system.

As per the discussion Getting Invalid port error and Invalid port. Exiting...

"Invalid port. Exiting..." occurs when the port assigned to chromedriver is less than 0 or greater than 65535.

Debugging steps

Perform the following steps to address the core issue:

  • Execute netstat command through CLI to see if you have reached limit of possible open connections or check if there is another application running on the port used by ChromeDriver.
  • Check your firewall settings, there is a good chance that firewall configuration may be blocking the communication.
  • Upgrade ChromeDriver to current ChromeDriver v2.84 level.
  • Upgrade Chrome to current Chrome v84.0 levels. (as per ChromeDriver v84.0 release notes)
  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • (WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
  • (LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
  • Take a System Reboot to free up the used ports.
  • Execute your @Test as non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Alternative

As an alternative you can force the WebDriver variant i.e. ChromeDriver to start on a specific port e.g. 65535 as follows:

  • Code Block:

    System.setProperty("webdriver.chrome.driver","C:\\WebDrivers\\chromedriver.exe");
    WebDriver driver= new ChromeDriver(new ChromeDriverService.Builder().usingPort(65535).build());
    driver.get("https://www.google.com/");
    
  • Console Output:

    Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 65535
    Only local connections are allowed.
    Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
    ChromeDriver was started successfully.
    Jul 20, 2020 7:36:17 PM org.openqa.selenium.remote.ProtocolHandshake createSession
    INFO: Detected dialect: W3C
    

References

You can find a couple of relevant detailed discussions in:

Upvotes: 0

Related Questions