【问题标题】:How do I take input using the gets module when using Frank and cucumber?使用 Frank 和 cucumber 时如何使用 gets 模块获取输入?
【发布时间】:2013-08-07 23:03:01
【问题描述】:

背景资料

我目前正在使用Frank with Cucumber 对 iOS 应用程序进行自动化测试。 一切正常运行,我可以对应用程序进行 Frankify、运行等。Symbiote 正常运行,Cucumber 也是如此。我已经编写了许多完全按照我的预期工作的测试步骤。我所有的步骤都是用 Ruby 编写的。

问题

我的问题是,由于一切正常,我希望能够有一个需要输入的步骤。我在想我可以只使用gets模块,但由于某种原因,它不等待任何用户输入,我只在功能失败后看到提示有效。 这是该步骤的代码:

    When(/^I verify the device via text$/) do
  print "What's the Verify link?"
  link_to_app = gets.chomp
  sleep 20
  press_home_on_simulator
  sleep 1
  # for this next part you're gonna need this link:
  # https://github.com/moredip/Frank/issues/177
  # It's used to go out of the app and open an html doc in safari
  html_format = "<!DOCTYPE HTML><html><head><title></title><meta http-equiv=\"refresh\" content=\"0;URL='#{link_to_app}'\"></head><boßdy></body></html>"
  html = html_format
  require 'tempfile'
  file = Tempfile.new(['launch', '.html'])

  begin
    file.write(html)
    %x( /usr/bin/open "#{file.path}" -a "iPhone Simulator" )
  ensure
    file.close
    file.unlink
  end

  sleep 2
end

这基本上是为了获取一个只能从 SMS 文本中获取的链接,并允许我在模拟器中自动转到该链接(这用于应用程序中的帐户验证)。 正如我之前所说,它不会提示停止并等待任何输入,而是直接跳过。

问题

基本上,在使用 Frank 和 Cucumber 时,我怎样才能使获取模块工作并为我接受输入?

谢谢

【问题讨论】:

  • 并不是所有的测试用例都可以自动化...

标签: ios ruby cucumber frank


【解决方案1】:

尝试使用 STDIN.gets,而不是普通的旧获取

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-23
    • 1970-01-01
    • 2018-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多