0
votes

I got the exception(below) when running Selenium with chrome driver version 74 on Linux server. It’s running just fine on Windows

unknown error: Chrome failed to start: exited abnormally (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.)

I can prevent this error by adding "--headless" into ChromeOptions, but some elements cannot be found when run Selenium with headless mode. my current ChromeOptions use as example below.

options = new ChromeOptions();
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--user-data-dir=something");
options.addArguments("--start-maximized");

I am Linux beginner, Can someone help me to know is it possible to run headful Selenium on Linux server and also how to do it?

1
you should find all the elements in headless mode as well. do you have an example of what you can't find? - Adi Ohana
@AdiOhana The element that missing in headless mode is a div element, I select by xpath(something like *//div[@id='xxx']). After I use headless Firefox instead of chrome(still run on Linux), selenium can found every elements that I need. However, it will be useful to know what is the issue of headless chrome and Is it possible to run heedful in Linux as well. - wittakarn
it is possible to run Chrome with selenium webdriver on a Linux machine with GUI, tough it is a bit complicated, I once did it following this article: tecadmin.net/setup-selenium-chromedriver-on-ubuntu if you can share some HTML examples, I can help try figure the headless Chrome issue - Adi Ohana
Chrome is located in one of four places on Linux. Are you finding/using the Chrome executable? My Python code to drive Chrome in a headless config uses this to locate Chrome. Then is sets options.binary_location = get_chrome(). - jww

1 Answers

0
votes

I can suggest you reinstall your chrome and use WebDriver Manager, with which you do not need to indicate the location of the binary file: for Java - https://github.com/bonigarcia/webdrivermanager for Python - https://github.com/SergeyPirogov/webdriver_manager