站点身份验证WebDriver代码接收 [英] Site Authentication webdriver codeception
问题描述
我正在编写一些自动化测试,并且我的测试需要连接到的站点需要站点身份验证。
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.
我尝试过通过url传递凭据,但这不起作用。任何建议表示赞赏。
I have tried using passing the credentials through the url, but that doesn't work. Any suggestions appreciated.
-
acceptance.suite.yml
acceptance.suite.yml
actor:AcceptanceTester
模块:
已启用:
-WebDriver:
浏览器:chrome
网址: http:// username:password @ my .site.autenticated.url
-\帮助程序\接受
这样我得到无法解析URI:http:// username:password@my.site.autenticated.url
推荐答案
这可能会帮助您:-
字符串密码= URLEncoder.encode( pass);
String Password = URLEncoder.encode("pass");
String UserName = URLEncoder.encode( UserName);
String UserName= URLEncoder.encode("UserName");
String url = String.format( http://%s:%s @ xyz ,用户名,密码);
String url = String.format("http://%s:%s@xyz", UserName, Password);
在此%s中,是一个以参数形式传递给url的变量。
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
这篇关于站点身份验证WebDriver代码接收的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!