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?