CodedUI - Windows Authentication in Chrome Browser

2019-02-21 04:06发布

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条回答
老娘就宠你
2楼-- · 2019-02-21 04:45

As @AdrianHHH suggested, the solution for this is:

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

This has been tested and working fine.

查看更多
看我几分像从前
3楼-- · 2019-02-21 05:09

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.

查看更多
登录 后发表回答