1

我正在尝试将 contentDescription 传递给自定义步骤定义,但收效甚微,我不确定我能做到,那里几乎没有帮助,所以我有点迷茫。

所以我启动了 calabash-android 控制台然后 start_test_server_in_background 然后查询(“TextView”)它返回 textView 中的元素列表,在这个列表中是 contentDescription,每个都有一个字符串值,例如“thisIsValue”

现在我在我的功能文件中写了一个步骤:

然后我触摸 contentDescription "thisIsValue" 文本

我的自定义步骤方法的语法是:

然后 /^I touch contentDescription text (\d+)$/ 做 |text, contentDescription| tap_when_element_exists("contentDescription contentDescription:#{arg1}")

我开始认为对于表单上相同文本的多个值来说,传递 contentDescription 是不可能的,由于在我们的实例中生成 xamarin 表单的方式,使用 ID 是不可能的,另一个选项将在索引上,但是这不是很好的前进。

谢谢大家。

格雷姆

4

2 回答 2

3

关于您的步骤定义,几乎没有可能出现错误的细节。

  1. (\d+)则表达式表明,您只在 contentDescription 中查找带有数字的元素。
  2. 您正在传递块一个值(上面提到的仅数字值),然后期望传递两个值(textcontentDescription)。
  3. 您应该点击 , 等类型的元素TextViewImageView*您想点击contentDescription元素。
  4. 您想点击contentDescription值为 的元素arg1,但arg1您的块内没有。
  5. 不要忘记contentDescription查询中 ' 值周围的撇号。

因此,您的步骤定义可能应如下所示:

Then /^I touch contentDescription text: (.*?)$/ do |arg1|
  tap_when_element_exists("TextView contentDescription:'#{arg1}'")
end
于 2015-04-28T06:02:22.643 回答
0

@kjuri - 您的解决方案现在已经奏效,看来在我的 Windows 环境设置中它正在查看不正确的步骤 def,我清除了文件夹并重新开始 - 基本上再次打开和关闭它!非常感谢您对此的耐心,以及您的帮助.. 确实非常感谢。总结一下这行得通:

然后 /^I touch the contentDescription "(.*?)" text$/ do |text| tap_when_element_exists("RadioButton contentDescription:'#{text}'") 结束

于 2015-04-28T11:38:39.207 回答