gpt4 book ai didi

android - 葫芦-android |请断言单选按钮自定义步骤帮助

转载 作者:行者123 更新时间:2023-11-29 20:48:16 25 4
gpt4 key购买 nike

我正在尝试在 xamarin 表单上的单选按钮上执行新闻事件。单选按钮的索引为 0 到 5。

如果我运行 query("RadioButton", :contentDescription) 这将返回 6 个单选按钮(索引从 0 到 5)。单选按钮没有唯一的文本,因为它们属于一组两个按钮,因此此处的索引值 2 到 5 是组 RadioGroup 的子项,所有文本标签都是相同的。

我想做的是在具有特定索引的 radioButton 上设置一个按下事件。

在我的功能文件中:然后我按 RadioButton 数字 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

我试图将索引值放在带有双引号或单引号或不带引号的特征文件中,但仍然出现错误。现在我完全迷路了......

有人有什么想法吗?

最佳答案

在查询中,您使用索引如下 查询(“单选按钮索引:0”)

所以你的步骤定义中的方法看起来像这样

tap_when_element_exists("RadioButton index:#{arg1}")

编辑:抱歉,我重新阅读了您的问题,但我之前并没有真正回答过它。为了让你的 then 步骤工作,你需要有一个包含

行的功能文件
Then I press RadioButton number 1

看起来您已经尝试过了,所以这不是问题所在。实际错误是说 calabash 看不到您编写的步骤定义。 Calabash 使用 Cucumber,这是处理场景和步骤定义等的位。Cucumber 在项目的“功能”目录中的任何位置查找步骤定义。如果您在这里创建一个文件并将您的步骤定义放入其中,那么它应该可供您的测试运行使用。

关于android - 葫芦-android |请断言单选按钮自定义步骤帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29850144/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com