处理 Windows 身份验证弹出窗口 [英] Handling Windows authentication pop up

查看:35
本文介绍了处理 Windows 身份验证弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的 AutoIt 脚本 (UI3_Authentication.au3),用于处理弹出的 Windows 身份验证.

Below is my AutoIt script (UI3_Authentication.au3) for handling a Windows authentication pop up.

AutoItSetOption("WinTitleMatchMode","2")  
WinWait("Authentication Required")   
$title = WinGetTitle("Authentication Required") ; retrives whole window title   
$UN=WinGetText($title,"User Name:")  
ControlSend($title,"",$UN,"test");Sets Username  
$PWD=WinGetText($title,"Password:")  
Send("{TAB 1}")  
ControlSend($title,"",$PWD,"test1234");Sets PWD  
Send("{ENTER}")  

<小时>

下面是我对上述 AutoIt exe 文件的 Selenium 代码调用.


Below is my Selenium code call to the above AutoIt exe file.

package tests;

import java.io.IOException;  
import org.openqa.selenium.WebDriver;  
import org.openqa.selenium.firefox.FirefoxDriver;  

public class Handling_Windows_Based_Prompt {

public static void main(String[] args) throws IOException{  
WebDriver c1 = new FirefoxDriver();  
c1.get("http://www.test.com");  
        Runtime.getRuntime().exec("C:\POM_Newdemo\EF_Automation_Demo\UI3_Authentication.exe");

}  
}

<小时>

当我运行上面的 Selenium 文件时,它会打开页面并弹出身份验证.但它没有插入用户名和密码;而是等待用户输入.


When I run the above Selenium file, it opens up the page and authentication pop up. But it is not inserting username and password; it waits for user input instead.

推荐答案

我解决了这个问题.事实上,这是我的错.以前,我的代码是这样的:

I resolved this. Actually, it was my bad. Previously, my code was like this:

c1.get("http://www.test.com");  
    Runtime.getRuntime().exec("C:\POM_Newdemo\EF_Automation_Demo\UI3_Authentication.exe");

<小时>

我在 get() 之前添加了 autoit 代码,如下所示,它起作用了:


I Added autoit code before my get() as follows, and it worked:

Runtime.getRuntime().exec("C:\POM_Newdemo\EF_Automation_Demo\UI3_Authentication.exe");
c1.get("http://www.test.com");

这篇关于处理 Windows 身份验证弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆