0

I am automating test cases for an application which requires an authentication to launch homepage. I am using below code to make it work.

String url = "http://i.user:i.password@baseURL_1/home";
driver.get(url);

Once I am inside the application , there is another link called "workflow" , clicking on which opens another application of same system. i.e. it redirects to http://baseURL_2/home.

While opening page from second application , browser(Chrome) authentication window re-appears. How do I handle it in automation script?

3 Answers 3

1

Try below code :-

WebDriverWait wait = new WebDriverWait(driver, 10);      
Alert alert = wait.until(ExpectedConditions.alertIsPresent());     
alert.authenticateUsing(new UserAndPassword(username, password));
Sign up to request clarification or add additional context in comments.

1 Comment

I think this is only for selenium 3.4 and implemented only for Internet explorer.
0

I see you've tried to pass the username and password within the URL. I had a similar issue a while back, the resolution for me was to whitelist my IP, this means the website wont request a username and password when you visit.

Hope this helps.

2 Comments

I am not aware of how to whitelist an IP. Can you share that info.
One of the developers did this for me in work, I assume you are doing this for work purposes? Give one of them a shout and they should be able to do this for you.
0
var alert = driver.SwitchTo().Alert();
alert.SetAuthenticationCredentials("username", "password");
alert.Accept();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.