0

我有下面的 autoIT 脚本可以在 Firefox 中上传文件。当我手动运行 autoit 脚本时它工作正常。但是当我在我的自动化 selenum 脚本中使用它时它不起作用。

自动脚本

$title = WinGetTitle("File Upload") ; retrives whole window title
WinWait("[CLASS:#32770]")``
WinActive($title)
WinActivate($title)
WinWaitActive($title)
Sleep(700)
send("!n")
Sleep(800)
Send("F:\Projects\MergeServerProject\File\OfflineAgreemntDocuments\DOC\File-1.docx")
Sleep(800)
Send("!o")

硒脚本

clickBrowserBtn(); //This function click on browse button in file upload control on FF
String[]templatenamenew=new String[] {"F:\\Projects\\f1\\scripts\\AutoIt\\FileUpload.exe"};
Runtime.getRuntime().exec(templatenamenew);

HTML 文件上传控件

笔记:

我也尝试使用 sendkey 功能,但它不起作用

4

1 回答 1

0

我注意到这没有得到回答,但这应该在 C# 中工作(不确定 Java,但你没有指定语言)。此行出现在您的 selenium 脚本单击打开窗口的按钮/字段之后。

Process.Start(@"C:\<source>\upload_something.exe", @"C:\<source>\myfile.jpg");

希望能帮助到你!

于 2013-01-29T17:34:38.670 回答