【问题标题】:Automating Authentication popup in SeleniumSelenium 中的自动身份验证弹出窗口
【发布时间】:2018-10-21 08:07:54
【问题描述】:

在 chrome 浏览器中自动弹出身份验证时,我有点挣扎。 我正在使用这个名为“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 脚本的外观。

WinWaitActive("Sign in")
Send("admin")
Send("{TAB}")
Send("admin")
Send("{ENTER}")

现在当我运行它时,弹出窗口中没有输入凭据,脚本根本没有运行。

请帮忙!

提前致谢。

【问题讨论】:

标签: java selenium autoit


【解决方案1】:

正如 Cruisepandey 所写,只有基本身份验证凭据可以直接添加到 url 中

其中一些凭据警报不是浏览器的组件,而是操作系统的组件。

这些弹出窗口无法通过 selenium 访问,如果可能的话,恶意软件可能会渗透。

BasicAuthentication 将您的凭据直接发送到 URL:https://{username}:{password}@host.com

带有手动输入凭据的 OAuth 需要基于 UIAutoamtion 的工具,例如:AutoITPython uiautomation

【讨论】:

    猜你喜欢
    • 2019-01-22
    • 1970-01-01
    • 2016-05-11
    • 1970-01-01
    • 1970-01-01
    • 2021-10-25
    • 2020-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多