Hello i have question for chromedriver. I want my own histories, cookies and all other things from my original chrome browser. if this is not possible how to use original chrome browser instead of driver?
2 Answers
you can use chrome profile (see below image to figure out which profile you want to launch)
- Default Profile :
Code :
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\***\\AppData\\Local\\Google\\Chrome\\User Data")
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', options=options)
driver.get("https://www.google.co.in")
- for customized profiles :
Code :
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\***\\AppData\\Local\\Google\\Chrome\\User Data")
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', options=options)
driver.get("https://www.google.co.in")
You can get profile while running chrome://version/ in Google chrome.
4 Comments
dasdasddas dsadasd
Hello im triyng the both of codes but nothing works. I don't see my history, and saved passwords from settings.
cruisepandey
@dasdasddasdsadasd : Did you check which profile you would want to launch the browser ? is it default or is there any customized profile ?
dasdasddas dsadasd
@cruisepandey yes, im using default: C:\Users\asshole\AppData\Local\Google\Chrome\User Data\Default
Alston
not working at all
You can import your default Chrome browser profile to be used by Selenium ChromeDriver as following:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\yourUserFolderName\\AppData\\Local\\Google\\Chrome\\User Data\\Default")
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options)
3 Comments
dasdasddas dsadasd
Hello im trying your code but i have a problem. nothing saves to driver and i can't login my gmail account because it says this browser is not secury.
Prophet
This will not help you login gmail. It detects browser managed by automatic toll (selenium) and blocks it.
dasdasddas dsadasd
I fixed problem with using this path: C:\Users\asshole\AppData\Local\Google\Chrome\User Data\Default
