0

All what im trying to do is pretty much access whatsapp web where I have my whatsapp already linked, However when I use a custom profile the profile does open, however browser.get("https://web.whatsapp.com) doesn't seem to open. or any browser.get(). What could be the issue?

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.common.exceptions import NoSuchElementException, TimeoutException, WebDriverException

options = webdriver.ChromeOptions()
options.add_argument('--user-data-dir=/Users/omarassouma/Library/Application Support/Google/Chrome/')
options.add_experimental_option("deatch", True)

browser = webdriver.Chrome(executable_path="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",chrome_options=options)
browser.get("https://web.whatsapp.com/")

this is the updated version, it now opens whatsapp web however not in a custom profile, moreover I cant really use webdriver.options(), is there anything extra I have to import?.

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager


options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=/Users/omarassouma/Library/Application Support/Google/Chrome/User Data/Default")
browser = webdriver.Chrome(executable_path="/Users/omarassouma/Downloads/chromedriver",options=options)
browser.get("https://web.whatsapp.com/")

1 Answers1

0

You need to take care of a couple of things as follows:

  • To use a Custome Chrome Profile you have to pass the absolute path as follows:

    options.add_argument("user-data-dir=/Users/omarassouma/Library/Application Support/Google/Chrome/User Data/Default")
    

You can find a detailed discussion in How to use Chrome Profile in Selenium Webdriver Python 3

You can find a detailed discussion in DeprecationWarning: use options instead of chrome_options error using Brave Browser With Python Selenium and Chromedriver on Windows

So effectively the line of code will be:

browser = webdriver.Chrome(executable_path="/path/to/chromedriver", options=options)
undetected Selenium
  • 151,581
  • 34
  • 225
  • 281
  • I edited my code according to what you said, but: 1) I did changes according to what you told me, however its not opening google in custom profile anymore but instead whatsapp web is opening 2) I don know how to use .options instead of chromeOptions it doesn't really let me use such option. – Omar Assouma Feb 09 '22 at 16:01
  • You still need to change `chrome_options=options` as **`options=options`** – undetected Selenium Feb 09 '22 at 16:03
  • Your right, i still did that and still its not working ( not opening custom google profile , but opening WhatsApp web works fine ) – Omar Assouma Feb 09 '22 at 16:08
  • @OmarAssouma How would you confirm _ not opening custom google profile_? – undetected Selenium Feb 09 '22 at 18:02
  • its opening google chrome using a guest and not a specific profile. Thus each time my code opens whatsapp web ill have to scan the barcode which is not really what I want to do. – Omar Assouma Feb 09 '22 at 21:26