How can I repeat steps?

53 views
Skip to first unread message

P. Pa.

unread,
May 1, 2017, 2:53:24 PM5/1/17
to calabash-android
Hi,

I want to test a register feature, so I have the following steps:

When(/^I fill the product field with "([^"]*)"$/) do |product|
enter_text "* id:'edtItem'", 'Item ' + "#{'product'}"
end

When(/^press the button addr$/) do
touch("* id:'btnAdd'")
end

I need to add 100 products. How can I repeat the these steps? I tried to use "while" but it did not work. I do not know if I did something wrong. 
Thanks,

Marcella

unread,
May 2, 2017, 9:14:48 AM5/2/17
to calabash-android
You could use the times method


100.times do 
  step "I fill the product field with "([^"]*)"
  step "touch("* id:'btnAdd'")"
end

P. Pa.

unread,
May 5, 2017, 12:49:54 PM5/5/17
to calabash-android
Thanks for your answer.
Should I do some update on .feature file?

This error is shown on console:

Ambiguous match of "I fill the item field with "Item 01"":

features/step_definitions/lista_steps.rb:6:in `/^I fill the item field with "([^
"]*)"$/'
...
...
...
...

Marcella

unread,
May 10, 2017, 9:04:09 AM5/10/17
to calabash-android
Seems like you have two step definitions that are the same (or almost the same). Try to find the duplicate step and refactor it.
Reply all
Reply to author
Forward
0 new messages