【问题标题】:Script for File Upload using Ruby/Capybara/autoIT使用 Ruby/Capybara/autoIT 上传文件的脚本
【发布时间】:2014-06-10 05:21:45
【问题描述】:

我正在尝试使用 Capybara 脚本上传文件。我从以下链接获得了一些帮助,我正在尝试使用以下链接中指定的 autoIT 选项:

Testing HTML5 File Upload with Capybara/Selenium Webdriver - Ruby

在上面的页面中,我对以下两行有疑问:

find_field(<<upload_file_id>>).click

system("<<full_path>>\\file_upload.exe \"#{<<file_path>>}\" \"File Upload\"")

感谢脚本,我用给定的代码创建了一个 .exe,并给出了上面两行以上传文件,但它给出了语法错误。

上述语法中的“文件上传”是什么?这是我要上传的文件的名称吗?我尝试了很多方法(正/反斜杠),但它返回Syntax error (syntax error, unexpected keyword_end, expecting ')' (SyntaxError))。这是我的语法。请建议并让我知道我缺少什么。赞赏这方面的建议。任何在语法中具有特定文件名的示例都会有帮助。

system("C:/Cucumber/cucumberdemo/features/file_upload.exe/"#     
{C:/Cucumber/cucumberdemo/Capybara.PNG}\"\File Upload\"")

system("C:\Cucumber\cucumberdemo\features\file_upload.exe\"#
{C:\Cucumber\cucumberdemo}\"\"Capybara.PNG\"")

system("C:/Cucumber/cucumberdemo/features//file_upload.exe/"#
{C:/Cucumber/cucumberdemo}/"/"Capybara.PNG/"")

system("C:/Cucumber/cucumberdemo/features/file_upload.exe/"#
{C:/Cucumber/cucumberdemo/Capybara.PNG}/"")

另外,System 命令是否也会单击对话框中的“打开”按钮,还是我需要为此编写单独的脚本?

【问题讨论】:

    标签: file-upload capybara autoit


    【解决方案1】:

    为什么不直接使用 Capybara 的 attach_file 方法?

    attach_file method

    【讨论】:

      【解决方案2】:

      试试这个 system("C:/Cucumber/cucumberdemo/features/file_upload.exe /"#
      {"C:/Cucumber/cucumberdemo/Capybara.png"}\ "\文件上传\"") 文件路径也应该放在你忘记的双引号中,比如

      {“文件路径”}

      【讨论】:

        猜你喜欢
        • 2015-12-19
        • 1970-01-01
        • 2013-12-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多