I am getting "failed to navigate: request unsuccessful: invalid session id" error from Open Link

The robot uses webdriver procotol to drive browsers. And to control a browser, the robot uses different drivers for each browser. Chrome has chromedriver, Firefox has geckodriver, Edge has edgedriver etc.

There are multiple reasons you may be getting this error, so we will go through all of them here and we assume you are using Chrome for your automations. Since that is our recommended browser in your flows anyway. :blush:

1. User Data Dir

Chrome browser has a feature called user-data-dir that lets you separate sessions from each other and also keep all the previous session info in different folders.

You can start chrome with --user-data-dir property like this

google-chrome --user-data-dir=C:\project-x-chrome

All the history, installed extensions and session info will be kept here from the opened browser session until you close it. If you give the same path again with this parameter and open Chrome again, it will continue from the previous session.

Your default chrome browser even works like this. It uses a default user data dir directory every time you open it. The Chrome user data dire default locations can be found here: User Data Directory

There is just one catch! You can’t open two chrome instances that use the same directory. Chrome will not start at all.

And this may be the main reason, you are getting this error in Robomotion.

If you do not provide a path to “Open Browser” User Data Dir property, chromedriver manages this by generating a temporary path for every Chrome session.

But if you provide a “User Data Dir” to Open Browser, then for every Open Link you should use “Same Tab” checkbox. If you do not do that, then a new window session will start that will try to use the same User Data Dir and you will get this error.

This won’t happen if you do not set “User Data Dir” in Open Browser, since every new Chrome window session will get its own tmp dir.

But if you want “New Window” + “User Data Dir” at the same time, then for every New Window with “Open Link” you should use an “Open Browser” with a different User Data Dir (or none) before the “Open Link” node.

2. There is no chromedriver on your machine

You need chromedriver.exe (Windows) or chromedriver binary (Mac and Linux) on your machine to drive Chrome Browser. You actually do NOT need to do anything here, the robot downloads and manages the right version needed for your Chrome.

But it is always a good idea to check if this binary exists on your system to make sure everything is in place. For Windows, the binary should be under %LOCALAPPDATA%/Robomotion/bin directory, for Linux and Mac it should be under $HOME/.config/robomotion/bin

3. Your chromedriver and Chrome versions do not match

Again the robot should handle this and should manage the right version downloads for you, but you can also check this one.

Open command prompt on Windows or Terminal on Linux/Mac

and run %LOCALAPPDATA%/Robomotion/bin/chromedriver --version command on Windows and $HOME/.config/robomotion/bin/chromedriver --version command on Linux/Mac, the output should be something like this:

~ $HOME/.config/robomotion/bin/chromedriver --version
ChromeDriver 98.0.4758.80 (7f0488e8ba0d8e019187c6325a16c29d9b7f4989-refs/branch-heads/4758@{#972})

and then run google-chrome --version command, the output should be something like this:

➜  ~ google-chrome --version       
Google Chrome 98.0.4758.80

The major versions should be same or chromedriver will not work, here we see the major versions are the same: 98.x.y.z

4. Not using Stable version but instead using a Beta or Canary version of Chrome

Robot or the chromedriver expects google-chrome binary on your system. The beta and canary version binaries are named differently. We only support the stable version of Browsers.

Download the latest stable Chrome version from Google Chrome - Download the Fast, Secure Browser from Google

5. Linux without a Desktop Environment

If you installed your Robot into a Linux machine where it does not have a Desktop. You are probably connecting to this machine via SSH. So you can’t expect a Chrome browser to open in a Desktopless environment. :slight_smile: But there is a way to do this actually, and that is called a Headless Browser session. It is easy to set up. Just go to the “Open Browser” node properties in your flow and select “Headless Chrome” from the list. Thats it!

So these are the cases for troubleshooting this error. If you are still getting this error, that would be another case we have missed, just reach out to us from this page or through our https://community.robomotion.io Discord community server.