处理Windows身份验证弹出 [英] Handling Windows authentication pop up
本文介绍了处理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()之前添加了自动代码,如下所示:
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屋!
查看全文