Calabash Android - 有没有一种无需包含字段即可输入文本的方法?

Calabash Android - Is there a way to input text without having to include the field?

有没有一种方法可以让我在脚本中输入文本

Then I enter "fgood2@hotmail.com"

而不是

Then I enter "fgood2@hotmail.com" into "edit_text_dialog_first_field"?

这是给葫芦的 Android。

谢谢

我建议您创建一个自定义步骤定义,然后您可以在您的方案中调用该步骤。使用预定义的步骤通常是不好的做法。

  • 在您的功能文件中创建一个名为 android_steps 的文件夹
  • 在该文件夹中创建一个名为 my_steps.rb 的文件(最终您会想要特定于一个的多个步骤文件,也就是着陆页、登录、菜单)
  • 使用正则表达式,您可以在 my_steps.rb 文件中创建步骤定义
  • 看起来像

    Then (/^I enter (.*)$/) do |information|
        touch("* id:'Field_id_you_want_to_enter_info_into'")
        keyboard_enter_text(information)
    end
    

我建议您创建一个更直观的步骤名称,尽管类似于我在用户名字段中输入 (.*) 我已经开始在 youtube 上创建介绍指南。请参考 https://www.youtube.com/playlist?list=PLInoIpH9dfLyvdaOjozON9QnQP1pK30y-

你可以写.feature文件,但是你必须写step definitions根据你的特点。

这个Then I enter "fgood2@hotmail.com或者这个Then I enter "fgood2@hotmail.com" into "edit_text_dialog_first_field"?都没有关系。

如果你使用

Then I enter "fgood2@hotmail.com" into "edit_text_dialog_first_field"?

您的步骤定义将是

Then (/^I enter "(.*?)" into "(.*?)$/") do | arg1, arg2 |
  do action...
end

如果你使用

Then I enter "fgood2@hotmail.com

您的步骤定义将是

Then (/^I enter "(.*?)") do | arg1 |
  do action...
end

是的,自定义步骤会更好,如果您需要一些示例,请试试这个 link here