【问题标题】:Autoit script for file upload does not work with selenium script用于文件上传的 Autoit 脚本不适用于 selenium 脚本
【发布时间】:2012-10-30 11:15:52
【问题描述】:

我有下面的 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 功能,但它不起作用

【问题讨论】:

    标签: selenium-webdriver autoit


    【解决方案1】:

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

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

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-15
      • 2014-06-10
      • 2014-08-05
      • 1970-01-01
      • 1970-01-01
      • 2015-12-19
      • 1970-01-01
      相关资源
      最近更新 更多