AutoIT脚本对我的Java代码没有任何作用
我使用TestNG框架和Selenium进行Web UI测试。我有一个要单击的文件下载对话框,为此我使用AutoIT 这是我处理Firefox fiel对话框的脚本,标题为“打开”AutoIT脚本对我的Java代码没有任何作用,java,path,autoit,Java,Path,Autoit,我使用TestNG框架和Selenium进行Web UI测试。我有一个要单击的文件下载对话框,为此我使用AutoIT 这是我处理Firefox fiel对话框的脚本,标题为“打开” 从未定义$timeout。您的脚本应该崩溃。尝试将ConsoleWrite()更改为MsgBox(),以查看它的运行情况。也尝试了此操作,但执行exe时的结果相同。当我手动尝试时,即打开文件对话框,然后从命令行运行AutoIT脚本,然后我可以看到ConsoleWrite/Msgbox显示,但它仍然没有单击对话框,可能
从未定义$timeout。您的脚本应该崩溃。尝试将
ConsoleWrite()
更改为MsgBox()
,以查看它的运行情况。也尝试了此操作,但执行exe时的结果相同。当我手动尝试时,即打开文件对话框,然后从命令行运行AutoIT脚本,然后我可以看到ConsoleWrite/Msgbox显示,但它仍然没有单击对话框,可能是因为它无法获得焦点。@Jai,但在AutoIT脚本中,您从未将$CmdLine[2]分配给$timeout,这一部分在这里被注释掉了:$title=WinGetTitle($CmdLine[1]);检索整个窗口标题$timeout=$CmdLine[2]
,在$timeout之前应该有一个换行符。哦,很抱歉,这里的格式是这样的,但在我的脚本中,它是指定的。
Opt("WinTitleMatchMode", -2)
If $CmdLine[0] < 2 Then
ConsoleWrite("Usage: " & @ScriptName & " <Opening> <timeout in seconds>" & @CRLF)
Exit(1)
EndIf
; File save dialog is titled "Opening <file>" in Firefox and "File Download" in IE.
$title = WinGetTitle($CmdLine[1]) ; retrives whole window title $timeout = $CmdLine[2]
; wait until dialog box appears
If WinWait($title, "", $timeout) Then ; match the window with substring
;ConsoleWrite("Found File save dialog" & @CRLF)
WinActivate($title)
Send("!S")
ControlClick("Opening", "", "[TEXT:&OK]")
Exit
Else
ConsoleWrite("File save dialog did not appear after " & $timeout & " seconds" & @CRLF)
Exit(2)
EndIf
final String type = getWebDriver().getClass().getName();
if (type.toLowerCase().contains("firefox")) {
exe = "SelectFileDialogOptions.exe";
commandLine = exe + " Opening " + 15;
} else {
//handle IE
}
logger.info("Executing the command '" + commandLine + "'...");
try {
final String[] commands = commandLine.split(" ");
Runtime.getRuntime().exec(commands);
} catch (final IOException e) {
throw new WebTestControllerException(
"Caught exception while trying to execute command '"
+ commandLine
+ "'. Exception is: "
+ e.getMessage());
}