在 Selenium 中自动化身份验证弹出窗口 [英] Automating Authentication popup in Selenium
问题描述
在 chrome 浏览器中自动弹出身份验证时,我有点挣扎.我正在使用这个名为http://the-internet.herokuapp.com/basic_auth"
I am struggling a bit while automating an authentication pop up in the chrome browser. I am using this test site named "http://the-internet.herokuapp.com/basic_auth"
这是我的代码.
public class Authen {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "C:\Users\Sumedha\OneDrive\Documents\Selenium\Drivers\chromedriver_win32\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://the-internet.herokuapp.com/basic_auth");
Runtime.getRuntime().exec("C:\Users\Sumedha\OneDrive\Documents\Selenium\AutoIT\handleauthentication.exe");
}
}
这就是我的 autoIT 脚本的样子.
This is how my autoIT script looks.
WinWaitActive("Sign in")
Send("admin")
Send("{TAB}")
Send("admin")
Send("{ENTER}")
现在,当我运行它时,弹出窗口中没有输入凭据,脚本根本没有运行.
Now when I run this, credentials are not entered in the popup and script does not run at all.
请帮忙!
提前致谢.
推荐答案
如 Cruisepandey 所写,只有 Basic Authentication 凭据可以直接添加到 url 中
as cruisepandey writes, only Basic Authentication credentials can be added direct into the url
其中一些凭据警报不是浏览器的组件,而是操作系统的组件.
where as some credential alerts are not browser's component, but OS's.
无法通过 selenium 访问这些弹出窗口,如果可能,恶意软件可能会渗透.
those pop-ups are not accessible via selenium, a malware could penetrate if it would be possible.
BasicAuthentication 将您的凭据直接发送到 URL:https://{username}:{password}@host.com
BasicAuthentication put your credentials direct to URL: https://{username}:{password}@host.com
带有手动输入凭据的 OAuth 需要一个基于 UIAutoamtion 的工具,一些示例:AutoIT 或 Python 用户界面自动化.
OAuth with Manually entered Credentials need a UIAutoamtion based tool, some examples: AutoIT or Python uiautomation.
这篇关于在 Selenium 中自动化身份验证弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!