1

I'm designing a tool using Selenium with Edge in python. I've got the following code.

from msedge.selenium_tools import Edge, EdgeOptions

edge_options = EdgeOptions()
edge_options.use_chromium = True
edge_options.add_argument("user-data-dir=C:\\Users\\XXX\\AppData\\Local\\Microsoft\\Edge\\User Data"); 
edge_options.add_argument("profile-directory=Default");

edge_options.binary_location = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
browser = Edge(EdgeChromiumDriverManager(log_level=30).install(), options=edge_options)
browser.get(url)

I'm succesfully creating a browser, however when there's already a browser opened I get the following error, which can be solved here. Ultimately it is kind of bad practice using Default profile, since the user interferes with the edgedriver.

user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir

There's multiple fixes, however creating a new profile is easiest by changing profiles.

edge_options.add_argument("profile-directory=Profile x");

This is where my trouble begins, the following options are given within the automated browser: Your admin needs you to sign in. To use profile x, please sign in or switch to a different account.

Basically I'm forced to create a second instance of the same account, switching me back to the initial default profile. Which only works if the user is not using Edge while the tool is running, something I cannot guarantee. Is there a workaround given I don't have admin rights?

  • According to your description, I found that this problem should be caused by setting the relevant group policy, simply refer to [Browser sign-in settings](https://learn.microsoft.com/en-us/deployedge/microsoft-edge-policies#browser-sign-in-settings). So you can't skip this group policy to achieve your needs. What you can do is log in as admin account, or modify this policy configuration mentioned aboved. – Xudong Peng Jan 28 '22 at 08:38

0 Answers0