【问题标题】:Unable to pass Windows Security authorization popup (protractor)无法通过 Windows 安全授权弹窗(量角器)
【发布时间】:2018-01-24 16:09:20
【问题描述】:

我在 IE 中遇到了授权问题。在我的情况下:我有 adfs 授权,它将我从我的站点重定向到 adfs,然后再次重定向到我的站点。

我试过这样:

browser.switchTo().alert().sendKeys("Text");

但这仅适用于第一个输入字段。

对于第二个输入字段:

browser.switchTo().alert().sendKeys(protractor.Key.TAB);

驱动程序失去焦点。

我用 Autoit 尝试了第二种方法:

helper.loginIE = function(name, password) {
    let formsAuthenticationArea = element.all(by.className(element)).get(0);
    formsAuthenticationArea.click();
   
    browser.call(function () {
        au.Init()
        au.WinWaitActive("Windows Security", "", 3);
        au.Send(name);
        au.Send("{TAB}");
        au.Send(password);
        au.Send("{ENTER}");                      
   })
};

Case with Autoit 与第一次点击元素异步工作。

node.js - 7.8.1;

量角器 - 5.2.2;

selenium-webdriwer - 3.8.1;

IEDriver - 3.7

IE11

capabilities: {
    'browserName': 'internet explorer',
    'ignoreProtectedModeSettings': true,
    'disable-popup-blocking': true,
    'enablePersistentHover': true,
    'nativeEvents': false,
    'unexpectedAlertBehaviour': 'ignore',
    'acceptSslCerts': true,
    'trustAllSSLCertificates': true
}

windows安全提示显示:

【问题讨论】:

    标签: internet-explorer protractor internet-explorer-11 windows-authentication basic-authentication


    【解决方案1】:

    您的身份验证对话框不是浏览器对话框,因此量角器无法原生自动,但您可以使用 nodejs 调用外部工具来自动它。

    选项 1) 使用 java.awt.Robot 类 Robot 是 JDK 中的内置类,因此您不需要其他库来实现此解决方案。

    一般步骤如下:

    1. 使用 Robot 类捕获身份验证对话框(可能通过对话框标题)
    2. 使用Robot类输入用户名和密码,点击确定按钮
    3. 将 java 类文件复制到量角器项目中
    4. 使用nodejs processchild-process或其他模块执行Java CMD 运行 java 类

    缺点:这个方案只能在浏览器在本地打开(使用directConnet或者seleniumAddress是localhost)时起作用。因为Robot类不能操作远程机器的桌面。

    要打破Robot 类的local 限制,一种方法是将上述类文件从脚本机器传输到远程浏览器机器。另一种可能的方法是使用Remote Robot,我从来没有尝试过,只是在谷歌中搜索。

    【讨论】:

      猜你喜欢
      • 2020-01-16
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      • 2016-03-07
      • 1970-01-01
      • 1970-01-01
      • 2017-07-21
      • 1970-01-01
      相关资源
      最近更新 更多