1

以下は、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 ファイルを実行すると、ページが開き、認証ポップアップが表示されます。ただし、ユーザー名とパスワードを挿入していません。代わりにユーザー入力を待ちます。

4

3 に答える 3

3

これを解決しました。実際、それは私の悪いことでした。以前は、私のコードは次のようでした:

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

次のように get() の前に autoit コードを追加したところ、機能しました。

Runtime.getRuntime().exec("C:\\POM_Newdemo\\EF_Automation_Demo\\UI3_Authentication.exe");
c1.get(“http://www.test.com”);
于 2013-01-31T08:49:16.540 に答える
0

これは私の ChromeDriver で動作します。それが役立つことを願っています

WinWait("data:, - Google Chrome","","10") ; this is the name of the window, according to AUTOIT v3 window info
If WinExists("data:, - Google Chrome","") Then
WinActivate("data:, - Google Chrome") ; set control to the window for proxy authentication
Send("putUsernameHere{TAB}") ; send username and press TAB
WinActivate("data:, - Google Chrome") ; again set control to our window, in case that we have clicked somewhere else
Send("putPasswordHere{ENTER}") ; send the password and press enter
EndIf
于 2014-04-17T10:21:13.010 に答える