How do I take input using the gets module when using Frank and cucumber?

332 views Asked by At

Background Info

I am currently using Frank with Cucumber to automate testing on an iOS app. Everything works as it should, I can Frankify the app, run it, etc. Symbiote works as it should, as does Cucumber. I've already written many testing steps that work exactly as I intended. All my steps are written in Ruby.

Problem

My problem is that, as everything works as it should, I want the ability to have a step that takes input. I was thinking I could just use the gets module, but for some reason it doesn't wait for any user input and I only see the prompt works after the feature fails. Here's the code for that step:

    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

This basically is meant to take a link that can only be taken from a SMS text and allow me to automatically go to that link in the simulator (this is used for account verification in the app). As I said before, instead of the prompt stopping and waiting for any input, it simply skips past.

Question

Basically, how can I, while using Frank and Cucumber, make the gets module work and take input for me?

Thank you

1

There are 1 answers

0
Pete Hodgson On

Try using STDIN.gets, rather than plain old gets