1

I’m trying to open a youtube page with my Chrome profile so I don’t have to sign in and do the MFA which ruins the automation. This is my code

 from selenium import webdriver from selenium.webdriver.chrome.options import Options import time url = 'https://www.youtube.com/'   options = webdriver.ChromeOptions()   options.add_argument(r"C:\Users\User01\AppData\Local\Google\Chrome\User Data\profile 1")   options.add_argument(r'--profile-directory=Profile 1')   driver = webdriver.Chrome(options=options)   driver.get(url) 

According to multiple sources online this code should do that but it is still opening the test browser.

I’ve tried multiple solutions online asked a few AI tools and no luck so far

    3 Answers 3

    1

    In my case this worked fine.

    ons = webdriver.ChromeOptions() ons.add_argument(f"--user-data-dir=C:\\Users\\{user_name}\\AppData\\Local\\Google\\Chrome\\User Data\\profile1") 

    Hope it helps.

    0
      0

      Maybe not your case, but anyway. Ones I was fighting with one allure issue very long. But appeared, it was not understanding a space in the path to the project dir. I noticed in your path '\User Data' with the spaces. Try to move it somewhere to the folder without any spaces in its name, e.g. UserData or any other folder.

      I am not guarantee it will solve your case, but according to your question you seems like tried all almost, so who knows if the reason is not in your setup but in something else.

        0
        WebDriverManager.chromedriver().setup(); // or pass the path for your driver ChromeOptions options = new ChromeOptions(); options.addArguments("user-data-dir=" + System.getProperty("user.home") + "\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2"); // else pass the path of your profile that you want to access. options.addArguments("profile-directory=Profile 2"); options.addArguments("--remote-allow-origins=*"); HashMap<String, Object> edgePrefs = new HashMap<String, Object(); edgePrefs.put("profile.default_content_settings.popups", 0); edgePrefs.put("plugins.always_open_pdf_externally", true); options.setExperimentalOption("excludeSwitches", new String[] {"enable-automation" }); options.setExperimentalOption("prefs", edgePrefs); RemoteWebDriver driver = new ChromeDriver(options); 
        1
        • Rather than a code-only answer, it's normally better to have an explanation as to exactly what your answer changes and how it resolves the problem in the question.
          – SmellyCat
          CommentedJun 4, 2024 at 4:09

        Start asking to get answers

        Find the answer to your question by asking.

        Ask question

        Explore related questions

        See similar questions with these tags.