2

Installation details

I have installed

  • java version : 1.8
  • selenium jar version : 3.141.59,
  • chrome browser version : 84.0.4147.89.

I want to launch the google in chrome browser using selenium web-driver test case. But I am not able to launch due the above attached issue.

Error snapshot

Please help me to fix the issue.

6
  • Need help to fix the above mentioned issue Commented Jul 20, 2020 at 10:44
  • Can you update the question with the text based error stack trace please? Commented Jul 20, 2020 at 13:02
  • thanks for response, I have done stack trace wit text based error,But didn't got exact solution to the problem Commented Jul 20, 2020 at 13:07
  • Please read why a screenshot of HTML or code or error is a bad idea. Consider updating the Question with formatted text based relevant HTML, code trials and error stack trace. Commented Jul 20, 2020 at 13:20
  • Thank you above suggestion helped me to understand exact issue. Commented Jul 23, 2020 at 10:00

6 Answers 6

2

This error message...

Invalid port. Exiting...
Exception in thread "main" org.openqa.selenium.WebDriverException: Driver server process died prematurely.

...implies that the ChromeDriver server process was 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.


Debugging steps

Perform the following steps one by one to address the 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:

Sign up to request clarification or add additional context in comments.

1 Comment

System rebooting helped me to resolved the issue, which is suggested by you. Thank you!!!
1

It seems that you are facing a problem with the driver configuration, it can be the configuration code, driver versions or Windows configuration or even the Browser itself. Here is a tutorial step by step on how to configure the basics properly:

Here is how to configure the code side and also the last version of chrome:

if you are working on a maven project I want to throw a suggestion: use: bonigarcia webdrivermanager library. Just add this to your pom

<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>3.2.0</version>
    </dependency>

and the configuration is much more simpler.

...
WebDriver driver= driverClass.getDeclaredConstructor().newInstance();
WebDriverUtils util = new WebDriverUtils(driver);
driver.get("google.com");
...

And that is it! With this you will need to worry much less about configuration of the driver, it automatically imports the driver and configures it for you. Here is a tutorial in case you wanna try.

Comments

0

You need to update your exe version https://chromedriver.chromium.org/downloads in this link you can download driver exe and set in path

Can you kill chrome exe and refresh and rerun ( note open cmd and paste this line and enter taskkill /im chromedriver.exe /f and rerun project

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

2 Comments

I have tired the above given solutions,but still I am facing same issue.
Please let me know ,any other alternate solution.
0

In my case it was that ChromeDriver version wss not compatible with Chrome Browser version. Make sure you are using the right versions.

Here you can find more information if you don't know which versions are compatible--> Which ChromeDriver version is compatible with which Chrome Browser version?

1 Comment

Thank you ,i have added the compatible driver and browser.
0

For the above problem, I understood what was root cause.

Mistake : I have done mistake of deleting system variable path while adding the JAVA_HOME in the environmental variable. Hence I do suggest,Please don't delete any system path while adding or editing the system variable.

Second thing : I have reset the window-10 operating system to get the exact system path,which supported me to execute the selenium test cases.

Because of setting incorrect system path in the environmental variable,My system operating system was unable to reach to specific browser driver's. which implies , that the Chrome-driver server process was unable to bind to the assigned free port within our system.

conclusion :The above issue got resolved for me, By resetting windows-10 OS. Install eclipse editor,JDK, selenium jar files,different drivers with respective browser and execute the test case.

I hope it will help to some one, who is facing same issue. Thanks..

Comments

0

I faced the same error and then I followed the steps shared at Timon/Web.com.

Step 1 — Find chromedriver binary path To find chromedriver binary path, run the following command in the terminal:

which chromedriver

The output should be similar to:

terminal output /usr/local/bin/chromedriver

Step 2 — Lift the quarantine for the chromedriver binary Now you need to tell Mac OS to trust this binary by lifting the quarantine. Do this by the following terminal command:

xattr -d com.apple.quarantine /usr/local/bin/chromedriver

Now, rerun your test or script, and it should be able to run chromedriver without the error.

Below is the link which I referred :

https://timonweb.com/misc/fixing-error-chromedriver-cannot-be-opened-because-the-developer-cannot-be-verified-unable-to-launch-the-chrome-browser-on-mac-os/

Its working fine for me. May be it will help you as well.

1 Comment

Hi, good first answer. Please use Markdown formatting to highlight code, commands and program outputs, in order to make the answer more readable. See stackoverflow.com/editing-help#code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.