以下は、Windows 認証ポップアップを処理するための AutoIt スクリプト (UI3_Authentication.au3) です。
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 コード呼び出しです。
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 ファイルを実行すると、ページが開き、認証ポップアップが表示されます。ただし、ユーザー名とパスワードを挿入していません。代わりにユーザー入力を待ちます。