undetected-chromedriver
undetected-chromedriver copied to clipboard
How to use UC with chrome portable?
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
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.
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, 👋
I managed to make it work by downgrading to selenium 4.9.