简体   繁体   中英

Error while using cucumber with rails for automated testing

I'm starting in the automated testing area and am having the error below when I am running one of my tests. The test would be to fill in a datetime field, of type input, with the start time that the machine stopped. I'm running Cucumber with Capybara on a system written in Ruby on Rails and Ext Js.

Error: wrong number of arguments (given 1, expected 0) (ArgumentError)

Bellow is my env.rb for the project:

require 'capybara'
require 'capybara/cucumber'
require 'report_builder'
require 'selenium-webdriver'
require 'webdrivers/chromedriver'

Capybara.javascript_driver = :webkit

Capybara.configure do |config|
    config.default_driver = :selenium_chrome 
    config.default_max_wait_time=10
    config.app_host='http://localhost:3000/'
end

My exemple.feature is like:

Scenario: start of the machine stop
Given that I accessed the system
And marked 'Yes' in 'Did the machine stop?'
And I fill the start of the machine stop with '2020-05-12 16:00:00' #UTC
When saving the form
Then the success message should appear

My steps.rb is something like below:

And("I fill the start of the machine stop with {string}") do
  @machine_stop = machine_stop
  @MD.machine_stop_start(@machine_stop)
end

My page.rb:

class Machine_downtime
    include Capybara::DSL

    def machine_stop_start
        find('input[id="datetimefield-1312-inputEl"]').click
    end
end

I've done a Google search to find possible solutions but I haven't found any similar cases. I tried to look at the Cucumber documentation but I didn't find anything specific to my problem or Rails. I can stop using a strings in the step and use a table, but I have more scenarios in this case and I would like to continue using strings, for easier maintenance and to avoid having to change more than 100 test scenarios.

I appreciate anyone who can help me with the problem.

Ps Ruby on Rails runs on a different project.

Update:

I insert in the machine_stop_start method the variable I created in the step and the error no longer occurs.

class Machine_downtime
    include Capybara::DSL

    def machine_stop_start (machine_stop)
        find('input[id="datetimefield-1312-inputEl"]').click
    end
end

Now I am able to click on the desired field but it is not being filled with the desired information. I will try to find what I may be doing wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM