Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is not possible to input text to a text field in a springboard alert #1420

Open
papatr0x opened this issue Jan 14, 2020 · 3 comments
Open

Comments

@papatr0x
Copy link

Currently I am trying to input a password in a textfield placed on a springboard alert. But command keyboard_enter_text() throws with "Keyboard is not visible", however keyboard is present on screen. Auto dismiss springboard alerts is disabled.

I looked into the code and it seems that query for keyboard into docked_keyboard_visible? function fails to get the right value.

The setup used for testing is:

  • iPhone 7 (iOS 13.3)
  • Xcode 11.3
  • Ruby 2.6.3 (with rbenv)
  • calabash-cucumber-0.21.10
  • run_loop-4.5.2
  • macOS 10.14
calabash-ios 0.21.10> keyboard_enter_text('password')
DEBUG: HTTP: post http://192.168.102.201:27753/1.0/dismiss-springboard-alerts {:retries=>200, :timeout=>20}
DEBUG: HTTP: post http://192.168.102.201:27753/1.0/dismiss-springboard-alerts {:retries=>200, :timeout=>20}
DEBUG: HTTP: post http://192.168.102.201:27753/1.0/dismiss-springboard-alerts {:retries=>200, :timeout=>20}
DEBUG: HTTP: post http://192.168.102.201:27753/1.0/dismiss-springboard-alerts {:retries=>200, :timeout=>20}
INFO: Embed is not available in this context. Will not embed.
Traceback (most recent call last):
        8: from /Users/ppalma/.rbenv/versions/2.6.3/bin/irb:23:in `<main>'
        7: from /Users/ppalma/.rbenv/versions/2.6.3/bin/irb:23:in `load'
        6: from /Users/ppalma/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/irb-1.2.1/exe/irb:11:in `<top (required)>'
        5: from (irb):1
        4: from (irb):2:in `rescue in irb_binding'
        3: from /Users/ppalma/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/calabash-cucumber-0.21.10/lib/calabash-cucumber/core.rb:743:in `keyboard_enter_text'
        2: from /Users/ppalma/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/calabash-cucumber-0.21.10/lib/calabash-cucumber/keyboard_helpers.rb:89:in `expect_keyboard_visible!'
        1: from /Users/ppalma/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/calabash-cucumber-0.21.10/lib/calabash-cucumber/failure_helpers.rb:75:in `screenshot_and_raise'
RuntimeError (Keyboard is not visible)
calabash-ios 0.21.10>
@jmoody
Copy link
Contributor

jmoody commented Jan 15, 2020

Try using device_agent.enter_text. Whenever you are interacting with a SpringBoard, use the device_agent APIs.

@papatr0x
Copy link
Author

papatr0x commented Jan 17, 2020

Hi @jmoody,
I've tried device_agent.enter_text() , this throws with "RuntimeError (Keyboard must be visible)", however keyboard in on screen.

calabash-ios 0.21.10> device_agent.set_dismiss_springboard_alerts_automatically(false)
DEBUG: HTTP: get http://192.168.102.201:27753/1.0/health {:retries=>1, :timeout=>0.5}
DEBUG: DeviceAgent says, "Calabash is ready and waiting."
DEBUG: HTTP: post http://192.168.102.201:27753/1.0/set-dismiss-springboard-alerts-automatically {:retries=>200, :timeout=>20}
false
calabash-ios 0.21.10> device_agent.enter_text("password")
DEBUG: HTTP: get http://192.168.102.201:27753/1.0/health {:retries=>1, :timeout=>0.5}
DEBUG: DeviceAgent says, "Calabash is ready and waiting."
DEBUG: HTTP: post http://192.168.102.201:27753/1.0/query {:retries=>200, :timeout=>20}
DEBUG: HTTP: post http://192.168.102.201:27753/1.0/dismiss-springboard-alerts {:retries=>200, :timeout=>20}
DEBUG: HTTP: post http://192.168.102.201:27753/1.0/dismiss-springboard-alerts {:retries=>200, :timeout=>20}
INFO: Embed is not available in this context. Will not embed.
Traceback (most recent call last):
        9: from /Users/ppalma/.rbenv/versions/2.6.3/bin/irb:23:in `<main>'
        8: from /Users/ppalma/.rbenv/versions/2.6.3/bin/irb:23:in `load'
        7: from /Users/ppalma/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/irb-1.2.1/exe/irb:11:in `<top (required)>'
        6: from (irb):26
        5: from /Users/ppalma/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/calabash-cucumber-0.21.10/lib/calabash-cucumber/device_agent.rb:307:in `enter_text'
        4: from /Users/ppalma/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/calabash-cucumber-0.21.10/lib/calabash-cucumber/device_agent.rb:467:in `with_screenshot_on_failure'
        3: from /Users/ppalma/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/calabash-cucumber-0.21.10/lib/calabash-cucumber/device_agent.rb:471:in `rescue in with_screenshot_on_failure'
        2: from /Users/ppalma/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/calabash-cucumber-0.21.10/lib/calabash-cucumber/failure_helpers.rb:88:in `fail'
        1: from /Users/ppalma/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/calabash-cucumber-0.21.10/lib/calabash-cucumber/failure_helpers.rb:75:in `screenshot_and_raise'
RuntimeError (Keyboard must be visible)
calabash-ios 0.21.10>

@jmoody
Copy link
Contributor

jmoody commented Jan 20, 2020

Try using the DeviceAgent.iOS http API.

https://github.com/calabash/DeviceAgent.iOS/blob/develop/Server/AutomationActions/Gestures/EnterText.m

POST /1.0/gesture
{
  "gesture" : "enter_text",
  "string" : "<string to type>"
}

Alternatively, use the RunLoop API directly.

I am not allowed to investigate defects in Calabash iOS because it is no longer supported by Microsoft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants