我正在尝试在 xamarin 表单上的单选按钮上执行按下事件。单选按钮的索引为 0 到 5。
如果我运行query("RadioButton", :contentDescription)
这将返回 6 个单选按钮(索引 0 到 5)。单选按钮没有唯一的文本,因为它们属于一组两个按钮,因此此处的索引值 2 到 5 是 RadioGroup 组的子项,所有文本标签都相同。
我想要做的是在具有特定索引的单选按钮上设置一个按下事件。
在我拥有的功能文件中:然后我按 RadioButton number 0
我创建了一个名为的自定义步骤定义radio_button_steps.rb
并将其保存到默认的 calabash-android 步骤定义文件夹
<driveLetter>:\Ruby193\lib\ruby\gems\1.9.1\gems\calabash-android-0.5.8\lib\calabash-android\steps
的语法radio_button_steps.rb
是:
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
结果返回:
Then(/^I press RadioButton number (\d+)$/) do |arg1|
pending # express the regexp above with the code you wish you had
end
我试图将索引值放在带有双引号或单引号或不带引号的功能文件中,但仍然出现错误。现在我完全迷失了......
有人有什么想法吗?