Load Chrome profile in Selenium

Asked

Viewed 1,336 times

1

I’m trying to upload my Chrome profile but can’t, which is missing?

from selenium import webdriver
from selenium.webdriver.chrome.options import Options


    class Teste:


        def __init__(self):
            self.driver = webdriver.Chrome()
            chrome_options = Options()
            chrome_options.add_argument("C:/Users/e5512459/AppData/Local/Google/Chrome/User Data/Default")
            brs = webdriver.Chrome(executable_path="C:/Users/e5512459/PycharmProjects/wpp/chromedriver.exe",
                                   chrome_options=chrome_options)

        def abrir(self):
            driver = self.driver
            driver.get("https://web.whatsapp.com/")


    wpp = Teste()
    wpp.abrir()

1 answer

1


There are a number of things that need to be done.

  1. You are creating two drivers and passing the Options in the second and accessing the site in the first.

  2. What argument would be used in the addargument in this case is the user-data-dir

  3. Another thing when passing the directory that is user information should be up to the User Data folder

At the end your code will look like this.


from selenium import webdriver
from selenium.webdriver.chrome.options import Options


class Teste():
    def __init__(self):

        chrome_options = Options()
        chrome_options.add_argument("user-data-dir=C:/Users/e5512459/AppData/Local/Google/Chrome/User Data")
        self.brs = webdriver.Chrome(executable_path="C:/Users/e5512459/PycharmProjects/wpp/chromedriver.exe", chrome_options=chrome_options)


    def abrir(self):
        driver = self.brs
        driver.get("https://web.whatsapp.com/")


wpp = Teste()
wpp.abrir()
  • even so it still does not load the profile, starts as a new profile

  • I changed the code a little bit, I believe that now will

  • 1

    @Filipe. C now the code is working

  • Thank you! solved here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.