I cannot get Undetected-ChromeDriver working on oracle A1 Ampere server with ubuntu 18.xx installed. I have latest available version of chromium and chromium-chromedriver and I can use everything normally when I use selenium library. But with undetected-chromedriver it fails.
Here is some info about my installed versions and system.
ubuntu$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic
ubuntu$ chromium-browser --version
Chromium 107.0.5304.87 Built on Ubuntu , running on Ubuntu 18.04
ubuntu$ file chromedriver
chromedriver: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=9a79cae5c2e9ad7ecbe2aea855e6a09b25cc4ed7, stripped
Here is the code which works:
from selenium.webdriver.chrome.options import Options
from selenium.webdriver import Chrome
import time
import os
copt = Options()
copt.add_argument('--headless')
copt.add_argument('--disable-web-security')
drv = Chrome(executable_path=os.getcwd() + '/chromedriver', options=copt)
drv.get('https://www.google.com/')
time.sleep(10)
drv.save_screenshot('screen_shot.png')
drv.quit()
According to my understanding this should also work but it just does not. I would be grateful if someone can shed some light. I also read that it can be because the chromedriver exists in a folder under root's control so I copied it from that folder to project folder.
import undetected_chromedriver
import time
import os
copt = undetected_chromedriver.ChromeOptions()
copt.add_argument('--headless')
copt.add_argument('--disable-web-security')
copt.add_argument("--remote-debugging-port=9222") #tried after researching, did not work
copt.add_argument("--disable-dev-shm-usage") #tried after researching, did not work
#copt.add_argument("--disable-gpu") #tried after researching, did not work
copt.add_argument("--crash-dumps-dir=/tmp") #tried after researching, did not work
copt.add_argument("--no-sandbox") #tried after researching, did not work
drv = undetected_chromedriver.Chrome(executable_path=os.getcwd() + '/chromedriver', version_main=107, options=copt)
drv.get('https://www.google.com/')
time.sleep(10)
drv.save_screenshot('screen_shot.png')
drv.quit()
Here is the output for undetected-chromedriver script:
ubuntu$ python3 main.py
Traceback (most recent call last):
File "main.py", line 83, in <module>
drv = CChrome()
File "/usr/local/lib/python3.6/dist-packages/undetected_chromedriver/__init__.py", line 53, in __new__
instance.__init__(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
These are the permissions for py file and chromedriver:
ubuntu$ ls -l
total 12892
-rwxr-xr-x 1 ubuntu ubuntu 13193696 Nov 20 15:50 chromedriver
-rw-r--r-- 1 ubuntu ubuntu 2264 Nov 20 19:28 main.py