Open luan1412167 opened 2 years ago
binary_location
argument specify the browser path not the driver path.
uc.Chrome()
docstring.Hi, 👋 I recently needed to use a portable chrome and spend many times and got figured it out.
I used some different resources and managed to make it work.
import os
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import undetected_chromedriver.v2 as undetected_chromedriver
options = Options()
# For portable setup
service = Service(os.getcwd() + "\\GoogleChromePortable\\chromedriver.exe") # Chromedriver path
options.binary_location = os.getcwd() + "\\GoogleChromePortable\\App\\Chrome-bin\\chrome.exe" # Portable Chrome path
options.add_argument("user-data-dir=" + os.getcwd() + f"\\GoogleChromePortable\\Data\\profile") # Portable Profiles, UC opens the last used profile
driver = undetected_chromedriver.Chrome(
service = service,
options = options,
version_main = 90,
)
Additional note, you don't need to add the "user-data-dir" argument, this is just how I use it.
Hope it'll help, 👋
I managed to make it work by downgrading to selenium 4.9.
Hey, thanks for great repo, Because UC downloads driver is slow, I want to use Chromeportable.exe for driver. I'm setting options.binary_location = Chromeportable_exe_path. Code is run fine but browser cannot close while my code closed. Can you help me fix it? Thanks so much