0

selenium==4.2.0
webdriver-manager==3.8.1

Description:
My task requires using specific edge profiles when displaying webdrivers in python/selenium to keep settings between sessions, ideally using the newer from selenium.webdriver.edge.options import Options with selenium.

Problem:
I tried following the top answers of
How to load default profile in Chrome using Python Selenium Webdriver?
How to open MS Edge with specific profile with selenium webDriver?
but using the newer selenium.webdriver instead of msedge.selenium_tools import Edge, EdgeOptions, as shown below:

from selenium import webdriver
from selenium.webdriver.edge.options import Options
from selenium.webdriver.edge.service import Service
from webdriver_manager.microsoft import EdgeChromiumDriverManager

options = Options()

# to find ur local user data dir, type <edge://version/> in edge
# path to profile user data
user_data_dir = (
    f"--user-data-dir=C:\\Users\\torjni\\AppData\\Local\\Microsoft\\Edge\\User Data"
)
options.add_argument(user_data_dir)

# actual profile
profile = f"--profile-directory=Profile 2"
options.add_argument(profile)

browser = webdriver.Edge(
    service=Service(EdgeChromiumDriverManager().install()),
    options=options,
)

browser.get("https://vg.no")

which is seemingly able to successfully open a new edge window and switch user, but throws the following error:

[11444:18732:0713/121606.202:ERROR:CONSOLE(5)] "Uncaught TypeError: cr.exportPath is not a function", source: edge://edge-guided-switch-background/guided_switch_background_page.js (5)         
[11444:18732:0713/121606.396:ERROR:CONSOLE(1)] "Uncaught ReferenceError: guided is not defined", source: edge://edge-guided-switch/ (1)
[11444:18732:0713/121606.626:ERROR:fallback_task_provider.cc(124)] Every renderer should have at least one task provided by a primary task provider. If a "Renderer" fallback task is shown, it is a bug. If you have repro steps, please file a new bug and tag it as a dependency of crbug.com/739782.  

and the browser/driver object does not respond to further commands such as browser.fullscreen_window() that would work without profiles, with error:

selenium.common.exceptions.WebDriverException: Message: unknown error: failed to change window state to 'fullscreen', current state is 'normal' 

QUESTION RECAP:
What is the preferred modern way of specifying non-default edge profiles in python/selenium with the newer selenium.webdriver.edge?

snoofalus
  • 1
  • 1

2 Answers2

0

Which version of Webdriver Manager are you using? You should use the latest version 3.8.1 of Webdriver Manager.

Besides, why do you use the below part of code? I don't think it's necessary. Your code will work without the below part and using Webdriver Manager 3.8.1.

options.add_argument("--allow-running-insecure-content")
options.add_argument("--ignore-certificate-errors")
options.add_experimental_option("useAutomationExtension", False)
options.add_experimental_option("excludeSwitches", ["enable-automation"])
Yu Zhou
  • 11,532
  • 1
  • 8
  • 22
  • Thank you for your message Yu. It's to show specific pages in kiosk mode that would otherwise throw warnings but i removed them from post since they aren't necessary for the Q. I was using 3.7.1 (probably installed w/ selenium) but upgraded to 3.8.1. Still shows same error "uncaught typeerror...", so there must be another way you're supposed to swap edge/chrome profiles in newer webdriver manager. – snoofalus Jul 14 '22 at 07:56
  • Can you reach the site `https://vg.no` successfully in automation? Which version of Edge and OS are you using? I use exactly the same code as yours(including `browser.fullscreen_window()`), it works well without errors. So you can reproduce the issue with just the code you provide in the thread? The file in the error message `edge://edge-guided-switch-background/guided_switch_background_page.js` seems to be Edge browser source file. I think the issue might be related with your Edge itself. Do you have another machine with Edge installed which can test again? – Yu Zhou Jul 15 '22 at 09:24
  • 1
    Thank you Yu Zhou. You were correct, it was an issue related to the local edge settings. Synchronization was deactivated, which in turn crashed the script. Opening that setting made it work as expected. – snoofalus Aug 24 '22 at 06:56
0

I've come to the similar problem. I use Administrator to login Windows 11, so I can't login my Microsoft Account under Administrator with error:" you can't login with personal account".

This is an inconvenience caused by the deep binding of edge's kernel to the system account, which also caused a strange problem like "Collections Not Sync Bugs": https://answers.microsoft.com/zh-hans/microsoftedge/forum/all/%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E7%9A%84edge/799a0822-ce07-452e-ad00-143741e26bc8

Nolca
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – user11717481 Feb 10 '23 at 14:35