2012-10-30 80 views
0

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

AutoIt脚本

$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本功能尝试离子,但它不起作用

回答

0

我注意到这并没有回答,但这应该在C#中工作(不确定Java,但你没有指定的语言)。这行是在你的硒脚本点击了打开窗口的按钮/字段之后。

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

希望它有帮助!