Home > database >  Cant open chrome profile with selenium
Cant open chrome profile with selenium

Time:10-02

I'm making a Whatsapp bot, but is doesn't let me open Whatssapp web without scanning the QR code. I have seen other questions on Stackoverflow with the same problem. It says that you need to open your chrome profile with chrome.

I have already tried to update Selenium, Pip, Pycharm etc, but it still doesn't work. Also, tried it with user-data-dir. But still nothing.

With chrome://version you can find the profile path of your chrome profile i copied the path and add it as an argument but still can't open my chrome profile with Selenium.

Also, made a second chrome profile and stored the folder somewhere else on my PC but that also doesn't work. Tried i lot of things but nothing seems to work, anybody else got these problems.

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

options = webdriver.ChromeOptions()
options.add_argument("/Users/maxbenenn/Library/Application Support/Google/Chrome")
options.add_argument("--profile-directory=Profile 2")

driver = webdriver.Chrome(service=Service("/Users/maxbenenn/Desktop/chromedriver"), options = options)
driver.get("https://web.whatsapp.com/")

CodePudding user response:

Mention your profile path like below:

from selenium.webdriver.chrome.service import Service

options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=C:\\Users\\<User>\\AppData\\Local\\Google\\Chrome\\User Data\\")
options.add_argument("--profile-directory=Default")  #if you want to use default profile, otherwise mention that specific profile's dir name here

driver = webdriver.Chrome(service=Service("/Users/maxbenenn/Desktop/chromedriver"), options = options)
driver.get("https://web.whatsapp.com/")

CodePudding user response:

https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/820

Here is the solution to your problem. Use undetected_chromedriver (powered by selenium) to sign in to google profile.

  • Related