Question:
I cant get chrome webdriver to work, i have seen fix that has to do with the nix file but i can’t find the file when i enable the show hidden file Repl link: https://replit.com/@kingsleyebubeon/Python#hey.py
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
chrome_options = Options()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
driver = webdriver.Chrome(options=chrome_options)
driver.get("https:/google.com")
## Finding Elements
google_text = driver.find_element(By.CLASS_NAME, "MV3Tnb").text
print(google_text)
input_box = driver.find_element(By.NAME, "q")
## Typing and Clicking
input_box.send_keys("Hi")
input_box.send_keys(Keys.ENTER)
home_link = driver.find_element(By.ID, "logo")
home_link.click()
## Selectors
tag_search = driver.find_element(By.TAG_NAME, "a").text
print(tag_search)
link_text = driver.find_element(By.LINK_TEXT, "About").text
print(link_text)
error text
Traceback (most recent call last):
File "/home/runner/Python/main.py", line 127, in <module>
scraper = IG_Scraper("https://www.dailyfx.com/sentiment#view-more", "sentiment_data.db")
File "/home/runner/Python/main.py", line 29, in __init__
self.driver = self.setup_driver()
File "/home/runner/Python/main.py", line 36, in setup_driver
return webdriver.Chrome(options=options)
File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
super().__init__(
File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 53, in __init__
self.service.start()
File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 102, in start
self.assert_process_still_running()
File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 115, in assert_process_still_running
raise WebDriverException(f"Service {self._path} unexpectedly exited. Status code was: {return_code}")
selenium.common.exceptions.WebDriverException: Message: Service /home/runner/.cache/selenium/chromedriver/linux64/118.0.5993.70/chromedriver unexpectedly exited. Status code was: 127
Thank you so much for the help, i got his error now
The chromedriver version (115.0.5790.98) detected in PATH at /nix/store/7ia44qd4nwn4ajcy1zq3zgv36lhg9k2m-chromedriver-115.0.5790.98/bin/chromedriver might not be compatible with the detected chrome version (118.0.5993.70); currently, chromedriver 118.0.5993.70 is recommended for chrome 118.*, so it is advised to delete the driver in PATH and retry
Traceback (most recent call last):
File "/home/runner/Python/main.py", line 127, in <module>
scraper = IG_Scraper("https://www.dailyfx.com/sentiment#view-more", "sentiment_data.db")
File "/home/runner/Python/main.py", line 29, in __init__
self.driver = self.setup_driver()
File "/home/runner/Python/main.py", line 36, in setup_driver
return webdriver.Chrome(options=options)
File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
super().__init__(
File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 56, in __init__
super().__init__(
File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 205, in __init__
self.start_session(capabilities)
File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 289, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 344, in execute
self.error_handler.check_response(response)
File "/home/runner/Python/.pythonlibs/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, 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 /home/runner/.cache/selenium/chrome/linux64/118.0.5993.70/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x556f9ffae783 <unknown>
#1 0x556f9fcda917 <unknown>
#2 0x556f9fd05978 <unknown>
#3 0x556f9fd029c9 <unknown>
#4 0x556f9fd42a13 <unknown>
#5 0x556f9fd4215f <unknown>
#6 0x556f9fd39bd3 <unknown>
#7 0x556f9fd0da7b <unknown>
#8 0x556f9fd0e81e <unknown>
#9 0x556f9ff6fe98 <unknown>
#10 0x556f9ff73d67 <unknown>
#11 0x556f9ff7e32c <unknown>
#12 0x556f9ff74993 <unknown>
#13 0x556f9ff43827 <unknown>
#14 0x556f9ff988a8 <unknown>
#15 0x556f9ff98a36 <unknown>
#16 0x556f9ffa75f3 <unknown>
#17 0x7f5e757c6dd4 start_thread
but looks like you’d tried going for the Xvfb template I mentioned for Firefox. You’ll have to “use” the template I mentioned; the cover page main.py gives you some code that I was testing on that repl to see if there’s a better solution for Chrome.
Or, I think you can just replace
with webdriver.Chrome() as driver:
with
with xvfbwrapper.Xvfb(), webdriver.Firefox(options=options) as driver: