Created
February 22, 2022 13:21
-
-
Save joewashington75/f845ae0a31cb3f0901e2c0de4a1ff868 to your computer and use it in GitHub Desktop.
Basic Authentication using Selenium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IWebDriver AzureAdRedirectWithAuthDetails(this IWebDriver driver, string userName, string password, string domainToReplace) | |
{ | |
Thread.Sleep(TimeSpan.FromSeconds(5)); | |
var newUrlWithUserCredentials = driver.Url.Replace(domainToReplace, $"{WebUtility.HtmlEncode(userName)}:{password}@{domainToReplace}"); | |
driver.Navigate().GoToUrl(newUrlWithUserCredentials); | |
return driver; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment