The browser extension does not work with Undetected Chromedriver. #2247
Closed
Kushalinfox
started this conversation in
General
Replies: 1 comment
-
|
done with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using this code. This code is working on selenium while in undected chromedriver. it is not installing. i tried options.argurments also. but it doesn't work
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from datetime import datetime
import os
Start timer
start = datetime.now()
=== Configurations ===
EXTENSION_DIR = r"C:\Users\Infox\AppData\Local\Google\Chrome\User Data\Profile 3\Extensions\majdfhpaihoncoakbjgbdhglocklcgno\3.6.3_0"
WEB_URL = "https://chromewebstore.google.com/detail/free-vpn-for-chrome-vpn-p/majdfhpaihoncoakbjgbdhglocklcgno"
=== Chrome Options Setup ===
chrome_options = Options()
Extension
extension_path = os.path.abspath(EXTENSION_DIR)
chrome_options.add_argument(f"--load-extension={extension_path}")
extension_file_path = os.path.abspath("C:/Users/Infox/AppData/Local/Google/Chrome/User Data/Profile 3/Extensions/majdfhpaihoncoakbjgbdhglocklcgno/3.6.3_0.crx")
chrome_options.add_extension(extension_file_path)
General browser configurations
chrome_options.enable_bidi = True
chrome_options.enable_webextensions = True
chrome_options.add_argument("--developer-mode")
chrome_options.add_argument("--enable-extensions")
chrome_options.add_argument("--extensions-on-chrome-urls")
chrome_options.add_argument("--disable-web-security")
chrome_options.add_argument("--allow-running-insecure-content")
chrome_options.add_argument("--enable-logging")
chrome_options.add_argument("--enable-ui-devtools")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("start-maximized")
chrome_options.add_argument("disable-infobars")
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_argument("--allow-chrome-scheme-url")
chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/114.0.0.0 Safari/537.36")
chrome_options.add_argument("--remote-debugging-pipe") # this will disable CDP
chrome_options.add_argument("--enable-unsafe-extension-debugging")
Mimic human behavior
chrome_options.add_experimental_option("useAutomationExtension", False)
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
=== WebDriver Initialization ===
driver = webdriver.Chrome(options=chrome_options)
Hide webdriver flag
driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
driver.execute_script("""
Object.defineProperty(navigator, 'languages', {get: () => ['en-US', 'en']});
Object.defineProperty(navigator, 'platform', {get: () => 'Win32'});
Object.defineProperty(navigator, 'vendor', {get: () => 'Google Inc.'});
""")
extension_result = driver.webextension.install(path=extension_path)
print(extension_result)
=== Actions ===
driver.maximize_window()
driver.get(WEB_URL)
Beta Was this translation helpful? Give feedback.
All reactions