Site Authentication webdriver codeception

人盡茶涼 提交于 2019-12-12 04:26:02

问题


I am writing some automation tests, and the site my test needs to connect to requires a site authentication.

I'm not sure how to handle this pop-up in order to provide the username & password. If the dialogue box is closed then the site can not be reached .. e.g. unauthorised access.

I have tried using passing the credentials through the url, but that doesn't work. Any suggestions appreciated.

  • acceptance.suite.yml

    actor: AcceptanceTester modules: enabled: - WebDriver: browser: chrome url: "http://username:password@my.site.autenticated.url" - \Helper\Acceptance

With this I get Unable to parse URI: http://username:password@my.site.autenticated.url


回答1:


Try doing this :

http://username:password@yourweburl/

example : -

driver.get("http://username:password@www.example.com/")



回答2:


This may help you :-

String Password = URLEncoder.encode("pass");

String UserName= URLEncoder.encode("UserName");

String url = String.format("http://%s:%s@xyz", UserName, Password);

In this %s is variable which pass to url in form of parameter .

You can refer this url also https://serverfault.com/questions/371907/can-you-pass-user-pass-for-http-basic-authentication-in-url-parameters



来源:https://stackoverflow.com/questions/45105254/site-authentication-webdriver-codeception

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