I am trying to perform a press event on a radiobutton on a xamarin forms. The radiobuttons are indexed 0 to 5.
If I run query("RadioButton", :contentDescription)
this will return 6 radioButtons (indexed 0 to 5). The radiobuttons do not have unique text as they belong to a group of two buttons, so index values 2 to 5 here are children of the group RadioGroup, the text labels are the same for all.
What I am trying to do is set a press event on the radioButton with a specific index.
In the feature file I have : Then I press RadioButton number 0
I have created a custom step definition called radio_button_steps.rb
and saved this to the default calabash-android step definition folder
<driveLetter>:\Ruby193\lib\ruby\gems\1.9.1\gems\calabash-android-0.5.8\lib\calabash-android\steps
the syntax of the radio_button_steps.rb
is:
Given /^I press the "([^\"]*)" RadioButton$/ do |text|
tap_when_element_exists("android.widget.RadioButton {text CONTAINS[c] '#{text}'}")
end
Then /^I press RadioButton number (\d+)$/ do |index|
tap_when_element_exists("android.widget.RadioButton index:#{index.to_i-1}")
end
The result is returning:
Then(/^I press RadioButton number (\d+)$/) do |arg1|
pending # express the regexp above with the code you wish you had
end
I've attempted to place the index values in the feature file with double or single or without quotes and still get the error. Now I am totally lost...
Anyone any ideas?
In queries you use indexes as follows query("RadioButton index:0")
So the method in your step def would look like this
tap_when_element_exists("RadioButton index:#{arg1}")
EDIT: Sorry I reread your question and I didn't actually answer it before. To get your then step to work you would need to have a feature file with the line
Then I press RadioButton number 1
Which it looks like you've tried, so that isn't the issue. The actual error is saying that calabash can't see the step definition that you've written. Calabash uses cucumber, which is the bit that handles scenarios and step definitions etc. Cucumber looks for step definitions anywhere inside the 'features' directory in your project. If you make a file in here and put your step definition in it, then it should be available for your test run to use.