0
votes

I want to open profile in selenium (for login in whatsapp for once) like the below code but when run my code chrome open a second tab with this url:http://%3D%20c/Users/Ali/AppData/Local/Google/Chrome/User%20Data/Default

from selenium import webdriver
from selenium.webdriver import ChromeOptions

PATH = "chromedriver.exe"
url = "https://web.whatsapp.com/"
CH_Option = ChromeOptions()
CH_Option.add_argument("user-data-dir = C:/Users/Ali/AppData/Local/Google/Chrome/User Data/Default")

Driver = webdriver.Chrome(PATH,options=CH_Option)
Driver.get(url)

......ScreenShot.....

2
Welcome to SO! Did you try calling the add_argument method with a raw (literal) string, e.g. CH_Option.add_argument(r"user-data-dir = C:/example")? - VirtualScooter
@VirtualScooter Thanks Mate you mean just put a 'r' before location string ? i did it but nothing changed - Ali Sadr
Actually, you might want to consider removing the spaces. An example that worked before: stackoverflow.com/a/52777900/5660315. - VirtualScooter
@VirtualScooter yeah it worked,I removed spaces in that string and chrome opened my profile, Thank You... - Ali Sadr

2 Answers

0
votes

To fix this, change the add_argument line to (removing the spaces in the string):

CH_Option.add_argument("user-data-dir=C:/Users/Ali/AppData/Local/Google/Chrome/User Data/Default")
0
votes
  1. Try to change / in your path to \\
CH_Option.add_argument("user-data-dir=C:\\Users\\Ali\\AppData\\Local\\Google\\Chrome\\User Data\\Default")
  1. Try to create a Guest user profile in your chrome driver and change the path to
CH_Option.add_argument("user-data-dir=C:\\Users\\Ali\\AppData\\Local\\Google\\Chrome\\User Data\\Guest Profile")