Chrome Webdriver loses user credentials in silent mode

I'm trying to set up mute chrome for CI selenium testing. Our web service uses AD for authorization. For whatever reason, when the chrome grille is set to headless mode, it gets "Access denied - 401.2" when trying to access any of our maintenance pages. But as soon as I run it fine (with a window as opposed to a headless one) everything works fine.

This is how I installed webdriver:

var chromeOptions = new ChromeOptions{
    BinaryLocation = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"/AppData/Local/Google/Chrome SxS/Application/chrome.exe"
};
chromeOptions.AddArguments(new List<string>() { "headless", "disable-gpu", "no-sandbox" });
var driver = new ChromeDriver(chromeOptions);
driver.Navigate().GoToUrl(mainPageURL);

      

After trying to run any tests with this setting (and getting 401.2) IIS logs something like this:

2017-06-23 11:25:12 ::1 GET / - 39731 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+HeadlessChrome...

      

But as soon as I remove the headless from the arguments, the logs look like this:

2017-06-23 11:26:15 ::1 GET / - 39731 [USER_LOGIN] ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome...

      

With my login instead of [USER_LOGIN].

So it seems that the username is lost during headless mode. So far I have been tied with impersification using the "profile-directory = Default" argument and running an older version of chrome (I'm currently on Canary 61.0.3138.0 64 bit - the newest available).

+3


source to share


1 answer


Just going out on a limb, but what does https: // user: pass@test.com / test do? That's why I asked what the mainPageURL consists of.

UPDATE:



Alert alert = wait.until(ExpectedConditions.alertIsPresent());     
alert.authenticateUsing(new UserAndPassword(**username**, **password**));

      

May be,?

0


source







All Articles