I'm trying to run the below code:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
options = webdriver.ChromeOptions()
options.binary_location = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
driver = webdriver.Chrome(service = Service(ChromeDriverManager().install()), options = options)
EDIT
I'm not sure I'm supposed to pass the chrome drive or the actual chrome app as the options argument, but even if I set either of the below (two different locations I have the chrome driver in) I still get the exact same message.
options.binary_location = "C:\\Program Files (x86)\\chromedriver.exe"
options.binary_location = "C:\\Users\\Tom\\Projects_Python\\Instagram_Image_Scraper\\chromedriver.exe"
I get the below error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 80, in __init__
super().__init__(
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 104, in __init__
super().__init__(
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 286, in __init__
self.start_session(capabilities, browser_profile)
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 378, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
self.error_handler.check_response(response)
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at C:\Program Files\Google\Chrome\Application\chrome.exe
Stacktrace:
#0 0x56380af48d93 <unknown>
#1 0x56380ad172d7 <unknown>
#2 0x56380ad3d3b2 <unknown>
#3 0x56380ad3ba3d <unknown>
#4 0x56380ad804f4 <unknown>
#5 0x56380ad77353 <unknown>
#6 0x56380ad46e40 <unknown>
#7 0x56380ad48038 <unknown>
#8 0x56380af9c8be <unknown>
#9 0x56380afa08f0 <unknown>
#10 0x56380af80f90 <unknown>
#11 0x56380afa1b7d <unknown>
#12 0x56380af72578 <unknown>
#13 0x56380afc6348 <unknown>
#14 0x56380afc64d6 <unknown>
#15 0x56380afe0341 <unknown>
#16 0x7f1c05443609 start_thread
My chrome version is: Version 110.0.5481.97 (Official Build) (64-bit)
Machine: Windows 11
I tried to assign the Chrome web driver to the variable 'driver' but it's giving me an error, I'm expecting to pass a web driver to the 'driver' variable so I can start pulling and scraping web pages.
Alternatives tried:
I tried to use a raw string to pass the chrome application location into the web driver, but this didn't work.
I tried to use the Firefox driver, but I see a similar issue about not having a binary.
Can anyone please help?
Try forward slash(//) instead of backslash(\) as below:
options.binary_location = "C://Program Files//Google//Chrome//Application//chromedriver.exe"
Try by passing the chromedriver.exe rather than chrome.exe
options.binary_location = "<full path here>//chromedriver.exe"
In case you do not have a chrome driver, here is the download link
Related
I am aiming to use my raspberry pi to test a webpage with python/selenium. The code works well on my desktop but the raspberry fail to handle the pop up:
driver = webdriver.Chrome()
driver.get("https://www.swoodoo.ch")
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//div[#aria-label='Schliessen']"))).click()
No problem on the desktop (ubuntu 22.04 or linux mint)
On the raspberry (raspberian or ubuntu 22.04) I get a timeout exception:
Traceback (most recent call last):
File "/home/user/flights/flights2.py", line 19, in <module>
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//div[#aria-label='Schliessen']"))).click()
File "/home/user/.local/lib/python3.9/site-packages/selenium/webdriver/support/wait.py", line 95, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
I tried the following (all below works well on the desktop!):
a) I manually click the banner away -> the whole program fine, incl. the functions to grad text out of a search result. However, it is not automated
b) I added waiting time (
time.sleep(x))
between all lines, long waiting time (30+) -> no change
c) I changed the code to the following:
driver = webdriver.Chrome()
driver.get("https://www.swoodoo.ch")
time.sleep(5)
element=driver.find_element(By.XPATH, "//div[#aria-label='Schliessen']")
time.sleep(5)
element.click()
-> The computer finds the Element but it is not clickable, error code:
Traceback (most recent call last):
File "/home/user/flights/flights2.py", line 23, in <module>
element.click()
File "/home/user/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 93, in click
self._execute(Command.CLICK_ELEMENT)
File "/home/user/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 401, in _execute
return self._parent.execute(command, params)
File "/home/user/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
self.error_handler.check_response(response)
File "/home/user/.local/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: chrome=104.0.5112.105)
Stacktrace:
#0 0x00557fda2268 <unknown>
#1 0x00557fbcbb08 <unknown>
#2 0x00557fbfd50c <unknown>
#3 0x00557fbf32d0 <unknown>
#4 0x00557fbf2cac <unknown>
#5 0x00557fc264c8 <unknown>
#6 0x00557fbf18f0 <unknown>
#7 0x00557fde52f4 <unknown>
#8 0x00557fde7b9c <unknown>
#9 0x00557fdd1cd4 <unknown>
#10 0x00557fde83bc <unknown>
#11 0x00557fdc6d64 <unknown>
#12 0x00557fe01cd0 <unknown>
#13 0x00557fe01e40 <unknown>
#14 0x00557fe1a6f0 <unknown>
d) Last idea was to use javascript for the click
driver.execute_script("arguments[0].click();", element)
-> No error message, no action
Anyone any ideas?
Generally <div> tags aren't clickable. So to click on the X icon you need to target the descendant <span> inducing WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:
Using CSS_SELECTOR:
driver.get('https://www.swoodoo.ch/')
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div[aria-label='Schliessen'] > span"))).click()
Using XPATH:
driver.get('https://www.swoodoo.ch/')
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[#aria-label='Schliessen']/span"))).click()
Note: You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Unable to create Python Chrome WebDriver in headless mode.
I am using Chrome version 108.0.5359.94.
I am also using the Service(ChromeDriverManager().install()) to automatically install the compatible chromewebdriver.
NOTE: The same result happens if I download the applicable chrome webdriver and instead of using the service I use the executable_path.
The code for recreating this is very simple.
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')
chrome_options.add_argument('--remote-debugging-port=9222')
chrome_options.add_argument('--no-sandbox')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
print(driver)
When running in regular (not headless) mode I am getting the expected print of the webdriver object:
python selenium_test.py
<selenium.webdriver.chrome.webdriver.WebDriver (session="9b6ec32017d8d864f8e2061293faee40")>
But when running in headless mode (same code simply remove the marker from the headless option line), I am getting the following error:
python selenium_test.py
Traceback (most recent call last):
File "/home/boazz/PycharmProjects/pythonProject/selenium_test.py", line 10, in <module>
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
super().__init__(
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 270, in __init__
self.start_session(capabilities, browser_profile)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 363, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 428, in execute
self.error_handler.check_response(response)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed.
(chrome not reachable)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x5588159a82a3 <unknown>
#1 0x558815766f77 <unknown>
#2 0x55881578f5f7 <unknown>
#3 0x55881578b7d0 <unknown>
#4 0x5588157cc0b7 <unknown>
#5 0x5588157cba5f <unknown>
#6 0x5588157c3903 <unknown>
#7 0x558815796ece <unknown>
#8 0x558815797fde <unknown>
#9 0x5588159f863e <unknown>
#10 0x5588159fbb79 <unknown>
#11 0x5588159de89e <unknown>
#12 0x5588159fca83 <unknown>
#13 0x5588159d1505 <unknown>
#14 0x558815a1dca8 <unknown>
#15 0x558815a1de36 <unknown>
#16 0x558815a39333 <unknown>
#17 0x7fa6443c0b43 <unknown>
I expected the chrome driver to be created regardless if I am using the headless option or not. What could be the cause for that?
The issue here is with a port you trying to set for debugging.
I tried your code and it did not work for me too, but when I changed the port from 9222 to 61625 it worked.
So, at least for me this worked:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
options = Options()
options.headless = True
options.add_argument('--remote-debugging-port=61625')
options.add_argument('--no-sandbox')
webdriver_service = Service('C:\webdrivers\chromedriver.exe')
driver = webdriver.Chrome(service=webdriver_service, options=options)
print(driver)
The output is
<selenium.webdriver.chrome.webdriver.WebDriver (session="70ca99a865d0eb7b93a95f530ef1401b")>
I have installed new Linux Mint in my computer.
I have installed Github, pycharm. I downloaded the code.
As per the packages requirement, i have installed the Selenium and other packages.
The code below which was working in previous Ubuntu Linux
Now it is downloading the code and its not working properly.
It is throwing the error.
For the first time, it is downloading the driver. Second time it is giving this error.
Both times the code is not working.
Please help me.
code:-
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
s = Service(ChromeDriverManager().install())
chrome_options = Options()
chrome_options.add_experimental_option("detach",True)
"""
The browser will be started.
"""
browser = webdriver.Chrome(service=s, options=chrome_options)
browser.maximize_window()
browser.get("https://rahulshettyacademy.com")
print(browser.title)
browser.get("https://rahulshettyacademy.com/angularpractice/")
print(browser.title)
Error message:-
/home/halovivek/PycharmProjects/yearcoding/venv/bin/python /home/halovivek/PycharmProjects/yearcoding/26092022_selenium1.py
Traceback (most recent call last):
File "/home/halovivek/PycharmProjects/yearcoding/26092022_selenium1.py", line 13, in <module>
browser = webdriver.Chrome(service=s, options=chrome_options)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
super().__init__(
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 270, in __init__
self.start_session(capabilities, browser_profile)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 363, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 428, in execute
self.error_handler.check_response(response)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
Stacktrace:
#0 0x55d1d6012693 <unknown>
#1 0x55d1d5e0bb0a <unknown>
#2 0x55d1d5e2e46e <unknown>
#3 0x55d1d5e2c1f4 <unknown>
#4 0x55d1d5e67953 <unknown>
#5 0x55d1d5e61743 <unknown>
#6 0x55d1d5e37533 <unknown>
#7 0x55d1d5e38715 <unknown>
#8 0x55d1d60627bd <unknown>
#9 0x55d1d6065bf9 <unknown>
#10 0x55d1d6047f2e <unknown>
#11 0x55d1d60669b3 <unknown>
#12 0x55d1d603be4f <unknown>
#13 0x55d1d6085ea8 <unknown>
#14 0x55d1d6086052 <unknown>
#15 0x55d1d60a071f <unknown>
#16 0x7f5a5a21a1da <unknown>
#17 0x7f5a5a2a2d84 <unknown>
Process finished with exit code 1
Modified the code as per advice .
import os
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.firefox import GeckoDriverManager
#options = Options()
options = webdriver.FirefoxOptions()
options.binary_location = r"/usr/bin/"
options.add_argument("start-maximized")
options.add_experimental_option("detach", True)
service = FirefoxService(log_path=os.devnull,)
browser = webdriver.Firefox(service= FirefoxService(GeckoDriverManager().install()), options=options)
#browser = webdriver.Firefox(service=service,options=options,)
capabilities = webdriver.FirefoxOptions().to_capabilities()
options.set_capability("cloud:options", capabilities)
browser.maximize_window()
browser.implicitly_wait(5)
browser.get("https://the-internet.herokuapp.com/windows")
print(browser.title)
Still error exist:-
/home/halovivek/PycharmProjects/yearcoding/venv/bin/python /home/halovivek/PycharmProjects/yearcoding/27092002_selenium3.py
[WDM] - Downloading: 16.2kB [00:00, 11.9MB/s]
Traceback (most recent call last):
File "/home/halovivek/PycharmProjects/yearcoding/27092002_selenium3.py", line 15, in <module>
browser = webdriver.Firefox(service= FirefoxService(GeckoDriverManager().install()), options=options)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 177, in __init__
super().__init__(
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 270, in __init__
self.start_session(capabilities, browser_profile)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 363, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 428, in execute
self.error_handler.check_response(response)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable
Process finished with exit code 1
Similar to Selenium gives "unknown error: cannot find Chrome binary" when running chrome driver on Ubuntu , it means that either Chrome is not installed on your system, or it's not installed in the default location where it would be found on your PATH. If Chrome is installed, but in a special location, you can set it like this (after you put in a valid path):
from selenium import webdriver
options = webdriver.ChromeOptions()
options.binary_location = "/PATH/TO/YOUR/CHROME"
driver = webdriver.Chrome(chrome_options=options)
If Chrome isn't installed at all on your Linux machine, you can try existing solutions such as https://stackoverflow.com/a/62234251/7058266 or https://www.digitalocean.com/community/tutorials/install-chrome-on-linux-mint in order to install it into the default location on your PATH.
Here's an example of Firefox headless mode on Linux:
import os
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
options = webdriver.FirefoxOptions()
options.add_argument("--headless")
capabilities = webdriver.FirefoxOptions().to_capabilities()
capabilities["moz:firefoxOptions"] = {"args": ["-headless"]}
options.set_capability("cloud:options", capabilities)
service = FirefoxService(
log_path=os.devnull,
)
driver = webdriver.Firefox(
service=service,
options=options,
)
### Do things here ###
driver.quit()
Good Morning Everyone.
Below the automation code in selenium with python.
It was working previously in past OS- ubuntu.
I have installed the new Mint Linux, installed the pycharm and downloaded the code from Github.
First time it is downloading the chrome driver and it gives the error.
Second time it is giving this error.
code:-
import time
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
s = Service(ChromeDriverManager().install())
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
#browser = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options=chrome_options, service_args=['--verbose', '--log-path=/tmp/chromedriver.log'])
browser = webdriver.Chrome(service=s, options=chrome_options)
#browser = webdriver.Chrome(options=Options)
browser.implicitly_wait(5)
"""
Going to use drag and drop
get the details from the mouse hover details
"""
browser.get("https://www.rahulshettyacademy.com/AutomationPractice")
browser.maximize_window()
print(browser.title)
#//a[normalize-space()='Top']
#//button[#id='mousehover']
action = ActionChains(browser)
Error Message:-
/home/halovivek/PycharmProjects/yearcoding/venv/bin/python /home/halovivek/PycharmProjects/yearcoding/22092022_selenium1.py
Traceback (most recent call last):
File "/home/halovivek/PycharmProjects/yearcoding/22092022_selenium1.py", line 16, in <module>
browser = webdriver.Chrome(service=s, options=chrome_options)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
super().__init__(
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 270, in __init__
self.start_session(capabilities, browser_profile)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 363, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 428, in execute
self.error_handler.check_response(response)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
Stacktrace:
#0 0x555ab50bc693 <unknown>
#1 0x555ab4eb5b0a <unknown>
#2 0x555ab4ed846e <unknown>
#3 0x555ab4ed61f4 <unknown>
#4 0x555ab4f11953 <unknown>
#5 0x555ab4f0b743 <unknown>
#6 0x555ab4ee1533 <unknown>
#7 0x555ab4ee2715 <unknown>
#8 0x555ab510c7bd <unknown>
#9 0x555ab510fbf9 <unknown>
#10 0x555ab50f1f2e <unknown>
#11 0x555ab51109b3 <unknown>
#12 0x555ab50e5e4f <unknown>
#13 0x555ab512fea8 <unknown>
#14 0x555ab5130052 <unknown>
#15 0x555ab514a71f <unknown>
#16 0x7f2b51a711da <unknown>
#17 0x7f2b51af9d84 <unknown>
Process finished with exit code 1
I dont know why this suddenly happening. I need solution to continue my learning and writing the code. Thank you.
Good day Ahead.
Since I could not able to find the solution.
I just reinstalled the whole operating system.
I installed Ubuntu again from Linux Mint.
Now the code is working fine.
thank you
I am trying to use undetected_chromedriver for bypassing Cloudfare Protection.
This is the simple code I am trying to use
import undetected_chromedriver as uc
from selenium import webdriver
import time
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
driver = uc.Chrome(options=options)
url = 'https://etherscan.io/tx/0x6b0e974952c7df4270cfb4aac332042af9b72c487e42d0bc04a676134118c1ac'
driver.get(url)
time.sleep(5)
print(driver.title)
However, I get the error :
Traceback (most recent call last):
File "test2.py", line 9, in <module>
driver = uc.Chrome(options=options)
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/undetected_chromedriver/__init__.py", line 401, in __init__
super(Chrome, self).__init__(
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 93, in __init__
RemoteWebDriver.__init__(
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 269, in __init__
self.start_session(capabilities, browser_profile)
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/undetected_chromedriver/__init__.py", line 589, in start_session
super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session(
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 360, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 425, in execute
self.error_handler.check_response(response)
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:58911
from chrome not reachable
Stacktrace:
#0 0x5622d155aad3 <unknown>
#1 0x5622d12ba3ff <unknown>
#2 0x5622d12a8ab9 <unknown>
#3 0x5622d12e0f69 <unknown>
#4 0x5622d12d8ee6 <unknown>
#5 0x5622d13142ba <unknown>
#6 0x5622d130e4e3 <unknown>
#7 0x5622d12e3d1a <unknown>
#8 0x5622d12e4e75 <unknown>
#9 0x5622d1588efd <unknown>
#10 0x5622d15a219b <unknown>
#11 0x5622d158ac65 <unknown>
#12 0x5622d15a2ec8 <unknown>
#13 0x5622d157e360 <unknown>
#14 0x5622d15bea68 <unknown>
#15 0x5622d15bebe8 <unknown>
#16 0x5622d15d87fd <unknown>
#17 0x7f129a6566db <unknown>
I am using the following versions :
Python 3.8
Google Chrome : 100.0.4896.75
ChromeDriver : 100.0.4896.60
undetected-chromedriver : 3.1.5.post4
selenium : 4.1.3
Usually I use chrome's default userdata-dir, for example: /home/vncuser/.config/google-chrome
I met the same problem sometimes, what I need to do just delete the preference file in the userdata-dir:
rm ~/.config/google-chrome/Default/Preferences
If the 'Preferences' file is too large(1~3 GB), the chrome will crash. The normal size of that file would be only a few KBs.
I had the same issue, while testing some new urls to scrape..
All was going well, until all the sudden I got the error :
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:58911
from chrome not reachable
Stacktrace: blablabla
Did as Chikong Ho suggested:
My profile folder was about 3 gig, so I delete my profile folder, and it runs like a charm again :)