2

I am using selenium server standalone jar- 3.11.0, latest ChromeDriver-2.36 and Chrome version 66.0.3359.139

My code

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

public class WebDriverBasics {

    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "C:\\Users\\surya\\Downloads\\Compressed\\chromedriver_win32_2\\chromedriver.exe");
        WebDriver driver=new ChromeDriver();
        driver.get("http://www.facebook.com");
        driver.manage().window().maximize();
    }
}

But i am unable to launch chrome.its giving below error

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.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
System info: host: 'DESKTOP-5GVJDVR', ip: '192.168.0.104', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', 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:545)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:132)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
    at WebDriverBasics.main(WebDriverBasics.java:12)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:????/status] to be available after ????? ms
    at 
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Suryaneel Varshney
  • 85
  • 1
  • 2
  • 13

6 Answers6

1

This error message...

Invalid port. Exiting...
?? ??, ???? ??:??:?? ????????? org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)

...implies that the OsProcess is unable to bind 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.

Solution

  • 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 given port.
  • Check your firewall settings, there is a good chance that firewall configuration may be causing the issue.
  • Upgrade ChromeDriver to current ChromeDriver v2.38 level.
  • Keep Chrome version at Chrome v66.x levels. (as per ChromeDriver v2.38 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot to free up the ports.
  • Execute your @Test.

Note : Steps 1, 2, 7 and 8 are vital to debug/solve the issue you are currently facing.


Alternative

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

  • Code Block:

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

    Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 65530
    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:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

Check whether the driver location is correct. I am able to launch Facebook without any issue.

package Practice;

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

public class Facebook 
{

    public static void main(String[] args) 
    {
        // TODO Auto-generated method stub

        System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe");


        WebDriver driver=new ChromeDriver();

        driver.get("http://www.facebook.com");


        driver.manage().window().maximize();

    }
}
Hannes
  • 3,752
  • 2
  • 37
  • 47
Siva K
  • 21
  • 5
0

change the date from Arabic (or what ever) to English date.

  • 2
    Please improve your answer by providing some information as to why this change will solve the problem. – otoomey Jan 19 '20 at 22:15
0

Try this code if you are facing an invalid port exiting error :

System.setProperty("webdriver.chrome.driver","C:\\Users\\Om Sai Ram\\workspace\\com.gmail\\chromedriver.exe" );
driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"), DesiredCapabilities.chrome());
driver.get("http://www.google.com");
driver.manage().window().maximize();
General Grievance
  • 4,555
  • 31
  • 31
  • 45
0

I'm from Iran. I also had this error and spent a lot of time for finding it. But eventually was solved by changing the setting of region in control panel to English.

0

that working after i use

 WebDriver dev= new ChromeDriver(new ChromeDriverService.Builder().usingPort(YOUR PORT).build());

you can get your port by open WebDriver app NOTE: keep ChromeDriver running