4

In my Selenium Tests I need to test a webpage where I use a basic Authen, Knowing that I am using Chrome Headless Java and Selenium WebDriver. On my machine 'locally' It works perfectly using driver.get("https://admin:admin@localhost.."); and then driver.get("https://localhost..") for example. I know that Chrome doesn't support this function anymore but I managed to make it work based on someone's solution here by passing the first URL with credentials and the second without. But when I run it on remote (Jenkins) On Linux servers I get the following Error

the configuration of your browser does not accept cookies

. I don't have vision on the servers when I can configure Chrome ..any ideas how to make it work without facing that problem.

I know a lot of people asked that question before, But I didn't find any valide answer for my issue.

Guillaume S
  • 1,462
  • 2
  • 19
  • 31
toto toto
  • 41
  • 5

3 Answers3

0

try ChromeDriver 2.45 (changelog) or change the location, where it is supposed to save the cookies:

ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");

otherwise (per default) it would create a new temporary directory each time it starts a session.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
0

ChromeOptions options = new ChromeOptions();

//Command line flag for enabling account consistency. The default mode is disabled.

options.addArguments("--account-consistency");

//Chrome that will start logging to a file from startup

options.addArguments("--log-net-log=C:/some_path/resource/log.json");

//Sets the granularity of events to capture in the network log.

options.addArguments("--net-log-capture-mode=IncludeCookiesAndCredentials");

Try this, basically, it saves the logs on startup of chrome browser, then it will set the account consistency. Anywhere from the log, you can debug the issue.

Manju
  • 21
  • 5
0

Hello I managed to fix the problem (I forgot to mention that our website is protected by Siteminder) so I did the following following:

1-We inject the USER and the PASSWORD on the URL :

The issue we faced was that the displayed prompt wasn’t part of the page’s HTML and it was hard for us to catch it using Selenium. We managed this by directly injecting the user login and the user password in the URL as follow : ‘https://USERNAME:PASSWORD@basicAuthentURL’ This will launch the Chrome session. Beware, this is only the first step of the process. The user identification have not been performed yet.

2- We create a new cookie :

After launching the URL, we have to manually create a cookie called « SMCHALLENGE » and add it to current session with Selenium, for example in JAVA : new Cookie("SMCHALLENGE", "YES");

3- Call the URL without the user credencials :

As the SMCHALLENGE cookie is now set, the last step is to call the URL again (https://basicAuthentURL ). The SMCHALLENGE cookie will be deleted once the authentication succeed and a SMSESSION cookie will be generated by Siteminder. The SMSESSION cookie now allows us to call the application and sucessfully pass Siteminder as if normally logged in (via SSO).

Let me know if you try this out.

toto toto
  • 41
  • 5