Reputation: 21
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/")
Upvotes: 0
Views: 2743
Reputation: 49
Thank you, I have been trying to find an answer to this for the last 4 hours scanning every page I can. I have tried about 10 different solutions. The problem is most of them are old. My solution does not need webdriver as it is built into Chrome now. Here is my code for reference for those looking for answers.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\<user>\\AppData\\Local\\Google\\Chrome\\User Data")
options.add_argument("--profile-directory=Default")
options.add_argument('--disable-gpu')
options.add_argument("--no-sandbox")
myurl = 'https://finance.yahoo.com/portfolio/p_4/view/view_6'
driver.get(myurl)
Upvotes: 1
Reputation: 1
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.
Upvotes: 0
Reputation: 2678
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/")
Upvotes: 1