How to fetch the file from local window by cucumber rails automation?

房东的猫 提交于 2019-12-25 00:39:21

问题


I use cucumber automation for my rails application. If I run the cucumber, It can't fetch the csv file from local window. My Step-definition file:

When("I upload a file") do
  attach_file("#{Rails.root}/rec.csv")
  sleep(2)
  click_button 'open'
  browser.button(xpath: '/html/body/div/form/input[4]').click
  sleep(2)
end

Error Shown:

Scenario: Uploading a valid csv file # features/user.feature:23 Given I visit the file upload page # features/step_definitions/user_step.rb:89 When I upload a file # features/step_definitions/user_step.rb:94 wrong number of arguments (given 1, expected 2..3) (ArgumentError) ./features/step_definitions/user_step.rb:95:in "I upload a file"' features/user.feature:25:inWhen I upload a file' Then the number of records are displayed # features/step_definitions/user_step.rb:102

Failing Scenarios: cucumber features/user.feature:23 # Scenario: Uploading a valid csv file

2 scenarios (1 failed, 1 passed) 6 steps (1 failed, 1 skipped, 4 passed) 0m16.032s

来源:https://stackoverflow.com/questions/48897808/how-to-fetch-the-file-from-local-window-by-cucumber-rails-automation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!