undetected-chromedriver icon indicating copy to clipboard operation
undetected-chromedriver copied to clipboard

How to use UC with chrome portable?

Open luan1412167 opened this issue 2 years ago • 2 comments

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

luan1412167 avatar May 23 '22 02:05 luan1412167

binary_location argument specify the browser path not the driver path.

  • Please read the uc.Chrome() docstring.
  • Please show some code to reproduce your issue.

sebdelsol avatar May 23 '22 18:05 sebdelsol

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.

My guide:

  • The best place to download! (This was my note for me 😄) Google Chrome Portable (64-bit) Download (2022 Latest)
  • Install a portable chrome from this site, I used "90.0.4430.72" chrome. For this setup, I used Chromedriver: 90.0.4430.24.
  • File structure
    • app.py
    • GoogleChromePortable folder
      • chromedriver.exe
  • Warning: Do not binary locate the "GoogleChromePortable.exe" in the GoogleChromePortable folder. Correct binary file's path is "\GoogleChromePortable\App\Chrome-bin\chrome.exe"

Here is my boilerplate code! app.py

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, 👋

hasansezertasan avatar Jul 16 '22 11:07 hasansezertasan

I managed to make it work by downgrading to selenium 4.9.

brrrada avatar Aug 04 '23 09:08 brrrada