Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unknown error: DevToolsActivePort file doesn't exist error while executing Selenium UI test cases on ubuntu

I have an ubuntu server having the UI as well. U can execute the test cases by firing mvn test command. But the problem is when I do ssh of the machine through the terminal from another machine I get the following error-

unknown error: DevToolsActivePort file doesn't exist
  (Driver info: chromedriver=2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7),platform=Linux 4.4.0-121-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.04 seconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'ubuntu-test', ip: 'X.X.X.X', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-121-generic', java.version: '1.8.0_171'
Driver info: driver.version: ChromeDriver

but the same command starts chrome successfully if I take remote of the machine through remmina and then execute the same command of this machines terminal.

like image 308
Nikunj Aggarwal Avatar asked Jun 11 '18 04:06

Nikunj Aggarwal


People also ask

How to fix “error - devtoolsactiveport file doesn't exist”?

Error: unknown error: DevToolsActivePort file doesn't exist The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed. This helped! Try reinstalling Chrome. Press: CTRL+T Then enter the commands:

What happened to JVM and selenium on Linux?

It appears that the only thing that changed was the google-chrome version (which had been updated to current) JVM and Selenium were recent versions on Linux box ( Java 1.8.0_151, selenium 3.12.0, google-chrome 67.0.3396.62, and xvfb-run). Specifically adding the arguments " --no-sandbox " and " --disable-dev-shm-usage " stopped the error.

How to create parsedevtoolsactiveportfile message in chrome?

According to chromedriver source code the message is created in ParseDevToolsActivePortFile method. This method is called from the loop after launching chrome process. In the loop the driver check if the chrome process is still running and if the ParseDevToolsActivePortFile file was already created by chrome.

What version of selenium is installed on Ubuntu Server?

Sign in to your account OS: Ubuntu Server 16.04 Selenium Version: Java, 3.12.0 Browser Version: 2.40


2 Answers

I use this configuration using python

import os
from selenium import webdriver 
from selenium.webdriver.chrome.options import Options 

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("no-sandbox")
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--headless")
driver = os.path.join("path/of/driver","chromedriver")

browser = webdriver.Chrome(executable_path=driver,chrome_options=chrome_options)
browser.get("https://www.example.com")
print(browser.title)
like image 124
Alex Montoya Avatar answered Sep 21 '22 03:09

Alex Montoya


I had a similar issue when I was trying to selenium UI test cases in headless mode. This occurred as I did not have a display server. Starting Xvfb worked for me.

sudo yum -y install Xvfb libXfont Xorg

sudo yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"

Xvfb :99 -screen 0 1024x768x24 &

export DISPLAY=:1

like image 33
mayuri tanksale Avatar answered Sep 19 '22 03:09

mayuri tanksale