calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 369 forks source link

Prompt user for something while running the test #1324

Closed vinamelody closed 7 years ago

vinamelody commented 7 years ago

Hi, how can I prompt user for a text while running the test, such as one time password?

I'm looking into something like this but the text is based on user's input.

Then /^I enter "([^\"]*)" into the "([^\"]*)" (?:text|input) field$/ do |text_to_type, field_name|
  touch("textField marked: '#{field_name}'")
  wait_for_keyboard
  keyboard_enter_text text_to_type
  sleep(STEP_PAUSE)
end

Thanks for help

jmoody commented 7 years ago

Use cucumber's ask method.

vinamelody commented 7 years ago

@jmoody do you mind to add link for example of using it with calabash-ios ? been trying to search for example but can't find it :(

I found one reference that suggests to use ENV variable here but I need it on the fly prompt

vinamelody commented 7 years ago

Goodness!! guess this needs to wait for another day for another fresh brain...! This should be the solution (case sensitive)!

Thanks @jmoody for the clue!

Then(/^I enter the secret$/) do
  print "What is the secret?"
  key = STDIN.gets
  wait_for_keyboard
  keyboard_enter_text key
  sleep(STEP_PAUSE)
end