Answer the question
In order to leave comments, you need to log in
How to change chrome profile in selenium?
I searched the internet for this issue, and this is what I found. That's just the entrance is not performed in an already existing profile, but a folder is created in the profile folder (sorry for the tautology) and everything is written there. Can I use an already existing Chrome profile?
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
options = webdriver.ChromeOptions()
options.add_argument(r"user-data-dir=C:\Users\Eugene\AppData\Local\Google\Chrome\User Data\Profile 4")
browser = webdriver.Chrome(executable_path=r'C:\Users\Eugene\Documents\Python\chromedriver.exe', chrome_options=options)
browser.get('https://www.google.com/')
Answer the question
In order to leave comments, you need to log in
It?
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from fake_useragent import UserAgent
options = Options()
ua = UserAgent()
userAgent = ua.random
print(userAgent)
options.add_argument(f'user-agent={userAgent}')
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\WebDrivers\ChromeDriver\chromedriver_win32\chromedriver.exe')
driver.get("https://www.google.co.in")
driver.quit()
Faced the same problem recently, try this:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
options = webdriver.ChromeOptions()
options.add_argument("--allow-profiles-outside-user-dir")
options.add_argument(r"user-data-dir=C:\Users\Eugene\AppData\Local\Google\Chrome\User Data")
options.add_argument("--profile-directory=Profile 4")
browser = webdriver.Chrome(executable_path=r'C:\Users\Eugene\Documents\Python\chromedriver.exe', chrome_options=options)
browser.get('https://www.google.com/')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question