javamicrosoft-edgeprofileselenium4

Bypass Edge Chromium profile Sign in screen in Selenium 4 Java(MacOS)


I know this question has been answered for Windows. Every time I try to automate Edge browser using Selenium 4, I get shown a profile window to select and then to sign in.

In Windows, you need to pass in the options.addArguments("--user-data-dir=C:\\Users\\<USER>\\AppData\\Local\\Microsoft\\Edge\\User Data");

to the options arguments followed by

options.addArguments("--profile-directory=Default");

But has anyone solved it for MacOS? Could not find a User Data folder under /Users/<USER>/Library/Application support/Microsoft Edge/ folder. It directly has Profile 1 folder for me. I tried various permutations and combinations to set the --user-data-dir and --profile-directory Nothing seems to be working for me.


Solution

  • The specific path should be based on your Profile path at edge://version, regardless of OS.

    For example, if you go to edge://version, and your Profile path is /Users/<USER>/Library/Application support/Microsoft Edge/Profile 1, your options should look like:

    options.addArguments("--user-data-dir=\\Users\\<USER>\\Library\\Application support\\Microsoft Edge");
    options.addArguments("--profile-directory=Profile 1");
    

    Additionally, it looks like you have BrowserSignin configured among your group policies. It would be easier to not configure this policy if possible.