0
votes

I'm using "Cross Browser Selenium Components" plugin to run codedui tests in Chrome browser. When i launch my web application, it needs windows authentication to log in to the website.

How do i pass the username and password along with the URL in coded UI?

Webdriver equivalent code is:

baseUrl=”http://” + username + “:” + password + “@” + url;

driver.get(baseUrl + “/”);

But in codedui, when i execute the below code, authentication window pops up but the control does not get past browser.NavigateToURL and hence i cannot provide username and password.

        BrowserWindow.CurrentBrowser = "chrome"; 
        string URL = "http://servername:portnumber/index.jsp";             
        BrowserWindow browser = BrowserWindow.Launch();
        browser.NavigateToUrl(new Uri(URL));

Any help would be highly appreciated please. enter image description hereenter image description here

2
I'm not sure I completely understand your problem with the popup. So the UITest navigates to the url and a popup window appears where you need to input a username and password? - PixelPlex
That's correct - when i launch it through IE, it popps up as Windows Security Pop Up whereas when i open the link through Chrome, it does not comes as Windows Security Popup and the driver is waiting for the page to load completely and we cannot provide username and password until it fails to launch. - Balaji Venkatachalam
Have attached the screenshot one from Chrome and the other from Internet Explorer. - Balaji Venkatachalam
Can you just write string URL = ”http://” + username + “:” + password + “@servername:portnumber/index.jsp”;? - AdrianHHH
Perfect - this is exactly what i was looking for - it works fantastic - thank you so much!!! - I was struggling to find a solution for almost over a week now and you helped to resolve it. - Balaji Venkatachalam

2 Answers

0
votes

As @AdrianHHH suggested, the solution for this is:

string URL = "http://" + username + ":" + password + "@servername:portnumber/index.jsp";

This has been tested and working fine.

0
votes

Answers given above are not wrong but including passwords in your code(or ini or config file for that matter) might not be the best way to go.

Always hide or encrypt your passwords.

You can go through this url on how to do that.