CodedUI - Windows Authentication in Chrome Browser

爷,独闯天下 提交于 2019-12-23 06:04:51

问题


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.


回答1:


As @AdrianHHH suggested, the solution for this is:

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

This has been tested and working fine.




回答2:


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.



来源:https://stackoverflow.com/questions/51736849/codedui-windows-authentication-in-chrome-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!