WebDriverError: no such session error using ChromeDriver Chrome through Jenkins and Selenium

Shan picture Shan · Apr 2, 2017 · Viewed 28.2k times · Source

Often I am getting no such session error when I am running the scripts from Jenkins. What's the cause for it? Is there any connection failure or is it due to someother reason (I am running around 26 scripts and out of it atleast one script has no such session error)

The scripts are different scripts and no such session error is not again repeated for the same scripts

Answer

caoglish picture caoglish · Jul 3, 2017

I met this kind of case sometimes. I use ChromeDriver with Laravel Dusk, rather than Selenium. However, I believe the cause is on ChromeDriver, not Selenium

ChromeDriver will create some cache files in folder:C:\Users\(yourAccountName)\AppData\Local\Temp. In this folder, you will see many cache folders that look like scoped_dir1234_5678. Each folder occupied around 10mb. If Jenkins runs ChromeDriver much frequently, ChromeDriver can overpopulate the cache file in the temp folder. You should think of 30-50GB cache files on your C drive and make full of your C driver.

When my C drive is out of space, ChromeDriver will not be able to start, and then return to me the error message "Facebook\WebDriver\Exception\NoSuchDriverException: no such session".

The solution:

  1. Go to the temp folder, remove all the ChromeDriver cache folders can clean up C space.
  2. Create the script which can remove/clean up the cache folder of ChromeDriver.

--UPDATE--

Find another situation to cause the issue.

If your run same script to start ChromeDriver in two different instance at same time on same OS, when one instance is finished and shut down the chromedriver, the other chrome browser instance might be closed as well.

For example you open the two console and execute chromeDriver script, or your Jenkins project start at the same time.

I believe even if you run different script but require chromeDriver at same time, one of the script will have "no such session" due to the chrome browser instance shutdown.

solution:

  1. Install the build blocker in jenkins
  2. Set up project in the build blocker, which target project need to wait it until it finished.

My case is using Laravel Dusk without selenium. I am not sure if it will make different when test go through selenium server