I’m trying to run some code that uses undetected_chromedriver but I’m getting the following error:
Traceback (most recent call last):
File "main.py", line 29, in <module>
driver = uc.Chrome(options=options)
File "/home/runner/firstReplit/venv/lib/python3.10/site-packages/undetected_chromedriver/__init__.py", line 421, in __init__
browser = subprocess.Popen(
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/subprocess.py", line 971, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/subprocess.py", line 1722, in _execute_child
and os.path.dirname(executable)
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/posixpath.py", line 152, in dirname
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
import undetected_chromedriver as uc
import asyncio
import time
import csv
import json
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from fake_useragent import UserAgent
# create a new undetected Chromedriver instance
options = uc.ChromeOptions()
# set options to run Chromedriver in headless mode
options.add_argument('--headless')
options.add_argument('--disable-gpu')
# set options to prevent Chrome from showing the "Chrome is being controlled by automated test software" notification
options.add_argument('--disable-logging')
options.add_argument('--disable-extensions')
options.add_argument('--disable-infobars')
options.add_argument('--disable-blink-features=AutomationControlled')
# set up user agent rotation
ua = UserAgent()
options.add_argument(f'user-agent={ua.random}')
# create a new undetected Chromedriver instance with the specified options
driver = uc.Chrome(options=options)
driver.get("https://www.target.com")
time.sleep(5)
driver.delete_all_cookies()
time.sleep(5)
# set up delay between requests
delay = 6
productlinks = []
async def fetch_data(link, idx):
u = driver.get(link)
time.sleep(delay)
try:
titleValue = driver.find_element(By.XPATH, '//h1[@data-test="product-title"]')
title = titleValue.get_attribute("innerText")
except:
titleValue = "Product not found"
pass
fields = {
"Title": titleValue
}
print(f"Product {idx}: {fields}")
return fields
Sorry, I’m unable to help with this, but maybe @not-ethan or @anon45021817, or @InvisibleOne could help you. Sorry, once again but I hope you enjoy your time with us!
Also having the same problem related to Chrome not being installed. Can anyone help?
My error says this:
Traceback (most recent call last):
File "main.py", line 81, in <module>
run_selenium()
File "main.py", line 20, in run_selenium
u_driver = uc.Chrome(use_subprocess=True)
File "/home/runner/Coupon-Bot/venv/lib/python3.10/site-packages/undetected_chromedriver/__init__.py", line 361, in __init__
options.binary_location = (
File "/home/runner/Coupon-Bot/venv/lib/python3.10/site-packages/selenium/webdriver/chromium/options.py", line 55, in binary_location
raise TypeError(self.BINARY_LOCATION_ERROR)
TypeError: Binary Location Must be a String
import csv
import os
import sys
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium import webdriver
import undetected_chromedriver as uc
import time
import random
def run_selenium():
# Create a new Chrome browser driver
u_driver = uc.Chrome(use_subprocess=True)
# Open the Google search results page for "dentists near me"
u_driver.get("https://www.wethrift.com/")
u_driver.maximize_window()
time.sleep(10)