问题
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