Skip to content

Instantly share code, notes, and snippets.

@joewashington75
Created February 22, 2022 13:21
Show Gist options
  • Save joewashington75/f845ae0a31cb3f0901e2c0de4a1ff868 to your computer and use it in GitHub Desktop.
Save joewashington75/f845ae0a31cb3f0901e2c0de4a1ff868 to your computer and use it in GitHub Desktop.
Basic Authentication using Selenium
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