1

My application does not have a login page to get authenticated. It uses my organizational email id (SSO) to authenticate my access to the application. I am using Version 80.0.361.66 (Official build) (64-bit) of Microsoft Edge.

driver = webdriver.Edge()
driver.maximize_window()

selenium version - selenium==3.141.0

This edge session does not use my work profile . It opens a new session because of which my work profile is not loaded and my access to the application is denied. However, I did try to update the version of selenium to use EdgeOptions. But, that didn't work as well. Below is the code :

options = webdriver.EdgeOptions() 
options.add_argument("user-data-dir=C:\\Users\\Ajmal.Moideen\\AppData\\Local\\Microsoft\\Edge\\User Data") 
driver = webdriver.Edge(options=options) 
driver.maximize_window() 

selenium version=4.0.0a3

Ajmal Moideen
  • 170
  • 1
  • 6
  • 17
  • Describe your SSO authentication process. Do you use a certificate or a password to login from a fresh browser? – pcalkins Mar 16 '20 at 21:38
  • Not entirely sure, but I'm interpreting https://learn.microsoft.com/en-us/microsoft-edge/webdriver-chromium#download-a-webdriver-language-binding to mean that you need `web driver.EdgeOptions(false)` to correctly initialise the Chromium version of edge. – Matthias Winkelmann Mar 17 '20 at 00:35
  • Thanks @MatthiasWinkelmann . I tried that as well now. However, the edge driver is not getting configured with the configuration in options – Ajmal Moideen Mar 17 '20 at 10:47
  • Basically, the SSO authentication uses a bearer token passed in the authorization header. @pcalkins – Ajmal Moideen Mar 17 '20 at 10:48
  • `options = webdriver.EdgeOptions(is_legacy=False) options.add_argument("user-data-dir=C:\\Users\\Ajmal.Moideen\\AppData\\Local\\Microsoft\\Edge\\User Data") options.add_argument("--start-maximized") driver = webdriver.Edge(options=options)` I tried adding a start-maximized argument to check if driver was accepting the options list. The browser was not getting maximized. – Ajmal Moideen Mar 17 '20 at 10:51
  • the token is usually set after login. What is the method of login for the auth server? – pcalkins Mar 17 '20 at 18:05

1 Answers1

3

Here's how I got it to work - I am using Chromium Edge 85.0.564.51 with Selenium 3.141.0.

Selenium 3.141.0 from pip doesn't seem to support new Chromium-based Edge Webdriver, but Microsoft supplies it in their msedge-selenium-tools package (better documentation here) as mentioned by Matthias' comment on your question.

First, grab the Chromium Edge webdriver here - get the version that matches your version of Edge (go to chrome:version in Edge to see what version you are running). Put the webdriver somewhere convenient, you need to set driverpath below to point to it.

Install the pip packages:

pip install msedge-selenium-tools selenium==3.141

In your code, import the msedge-selenium-tools Webdriver and Options modules and build the webdriver as shown:

from msedge.selenium_tools import Edge, EdgeOptions

...

options = EdgeOptions()
options.use_chromium = True
options.add_argument("--user-data-dir=C:\\Users\\YOUR-USERNAME\\AppData\\Local\\Microsoft\\Edge\\User Data")
options.add_argument("--start-maximized")
driverpath = 'msedgedriver.exe'

driver = Edge(driverpath, options=options)

Voilà, that should do the trick.

P.S.: Even though chrome:version will show your Profile path with a trailing \Default, don't include that in your --user-data-dir argument above, since the driver seems to append \Default to the end.

datu-puti
  • 1,306
  • 14
  • 33