WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium through Python on VPS
This error message...
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.15.0-42-generic x86_64)
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
There are exactly two incompatibility issues as discussed below.
disable-gpu
When Headless Chrome was first released as GA (General Availability) by Google Team the article Getting Started with Headless Chrome
mentioned that :
--disable-gpu \ # Temporarily needed if running on Windows.
A note was added as :
Right now, you'll also want to include the
--disable-gpu
flag if you're running on Windows.
As per the discussion Headless: make --disable-gpu flag unnecessary it was clear that :
The
--disable-gpu
flag is no longer necessary on Linux or Mac OSX. It will also become unnecessary on Windows as soon as the bug SwiftShader fails an assert on Windows in headless mode is fixed. Now as this issue is marked fixed the argument--disable-gpu
should be redundant now.
Note: You can find a detailed discussion in ERROR:gpu_process_transport_factory.cc(1007)-Lost UI shared context : while initializing Chrome browser through ChromeDriver in Headless mode
However, your main issue is the incompatibility between the version of the binaries you are using as follows:
- You are using chromedriver=2.30
- Release Notes of chromedriver=2.30 clearly mentions the following :
Supports Chrome v58-60
- Your chrome version is unknown to us. Assuming you are using on of the latest Chrome releases either among:
Chrome version 71
Chrome version 72
Chrome version 73
So there is a clear mismatch between ChromeDriver v2.30 and the Chrome Browser v71-73
Solution
- Depending on your Chrome Browser version upgrade ChromeDriver accordingly following the guidelines below:
- If you are using Chrome version 73, you need to download ChromeDriver 73.0.3683.20
- If you are using Chrome version 72, you need to download ChromeDriver 2.46 or ChromeDriver 72.0.3626.69
- If you are using Chrome version 71, you need to download ChromeDriver 2.46 or ChromeDriver 71.0.3578.137
- For older version of Chrome, see this discussion for the version of ChromeDriver that supports it.
References
You can find a couple of relevant discussions in:
- OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally while executing tests through Selenium start on linux
- WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium on debian server
- Message: unknown error: Chrome failed to start: exited abnormally on AWS Cloud9 with Linux 4.9.85-38.58.amzn1.x86_64 x86_64
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally using Selenium ChromeDriver and Chrome through WebDriverManager
You need to take care of a couple of things here as follows:
You need
webdriver.Chrome()
only once. If you don't need the arguments throughOptions()
keep:driver = webdriver.Chrome(service=service)
and remove:
driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)
or vice versa.
If you are executing as a non-root using
add_argument('--headless')
generally you may not even require the following arguments:add_argument('--no-sandbox')
add_argument('--disable-dev-shm-usage')
You can try to initiate the new Browsing Context i.e. google-chrome-headless using:
driver = webdriver.Chrome(service=ChromeDriverManager().install(), options=chrome_options)
Your effective code block will be:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
chrome_options = Options()
chrome_options.add_argument('--headless')
# optional
chrome_options.add_argument('--no-sandbox')
# optional
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(ChromeDriverManager().install(),options=chrome_options)
driver.get('http://192.168.15.1/me_configuracao_avancada.asp')
Note: Ensure that you have installed webdriver-manager and Chrome browser within your system before you kickoff your test execution.
WebDriverException: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist)
This is for java, but I think it should work for you to:
https://github.com/SeleniumHQ/selenium/issues/4961#issuecomment-346821657
It says that is is a permission issue. Try running your program as root.
Related Topics
Using Multiple Layers of Quotes in Bash
How to Split Two Vertical Pane Inside a Horizontal Pane in Tmux Using Tmuxinator
Linking a Static Library into a Shared Library
List of Files Modified 1 Hour Before
Analog of Com Programming in Linux/Unix
The Difference Between Wait_Queue_Head and Wait_Queue in Linux Kernel
While Using Printf How to Escape Special Characters in Shell Script
How to Zip Folder That Contains More Than 12Gb Data
Srlua Makefile Error Lua.H No Such File or Directory
Dos2Unix: Binary Symbol Found, Skipping Binary File
How to Execute The Vim Commands Through Shell Script
Run Any Linux Terminal Command from Typescript
Linux: Find a List of Files in a Dictionary Recursively
Intel Fortran Composer 2011 and Linux Mint 12
$${Home} or ${Home} in Makefile