calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 369 forks source link

In my app's safari webview, keyboard_visible? command returns "false" while the device_agent.keyboard_visible? command returns "true" #1166

Open AlexWellsHS opened 8 years ago

AlexWellsHS commented 8 years ago

While in my app's Safari webview (for facebook authentication), after touching a text field and allowing the keyboard to become visible, the keyboard_visible? command returns "false" while the device_agent.keyboard_visible? command returns "true"

Environment: /Applications/Xcode.app/Contents/Developer Xcode 8 - build 8A218a Calabash-ios version 0.20.0 iPhone 6s (iOS 10 simulator)

{"device_family":"iPhone","outcome":"SUCCESS","server_port":37265,"simulator_device":"iPhone","simulator":"CoreSimulator 303.8 - Device: iPhone 6s - Runtime: iOS 10.0 (14A345) - DeviceType: iPhone 6s","app_name":"#####","app_version":"137","screen_dimensions":{"native_scale":2,"sample":1,"height":1334,"width":750,"scale":2},"git":{"revision":"3427493","remote_origin":"git@github.com:calabash\/calabash-ios-server.git","branch":"master"},"device_name":"alexWells","4inch":false,"app_id":"####","form_factor":"iphone 6","system":"x86_64","version":"0.20.0","iOS_version":"10.0","short_version_string":"2.9.1","ios_version":"10.0","iphone_app_emulated_on_ipad":false,"model_identifier":"iPhone8,1","app_base_sdk":"iphonesimulator10.0"}

Using Cocoapods with calabash 0.20.0 pod

Console:

#<Launcher: DeviceAgent/ios_device_manager>
calabash-ios 0.20.0> touch("* marked:'Email or Phone'")
INFO: Embed is not available in this context. Will not embed.
RuntimeError:
Could not find any views with query:

  * marked:'Email or Phone'

Make sure your query returns at least one view.

    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/failure_helpers.rb:75:in `screenshot_and_raise'
    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/automator/device_agent.rb:329:in `query_for_coordinates'
    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/automator/device_agent.rb:90:in `touch'
    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/core.rb:1713:in `query_action_with_options'
    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/core.rb:290:in `touch'
    from (irb):2
    from /Users/alexwells/.rbenv/versions/2.3.1/bin/irb:11:in `<main>'
calabash-ios 0.20.0> device_agent.touch({marked:"Email or Phone"})
{
    "status" => "success"
}
calabash-ios 0.20.0> keyboard_visible?
false
calabash-ios 0.20.0> device_agent.keyboard_visible?
true
calabash-ios 0.20.0> keyboard_enter_text("Hello")
INFO: Embed is not available in this context. Will not embed.
RuntimeError: Keyboard is not visible
    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/failure_helpers.rb:75:in `screenshot_and_raise'
    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/keyboard_helpers.rb:89:in `expect_keyboard_visible!'
    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/core.rb:684:in `keyboard_enter_text'
    from (irb):9
    from /Users/alexwells/.rbenv/versions/2.3.1/bin/irb:11:in `<main>'
calabash-ios 0.20.0> device_agent.keyboard_enter_text("Hello")
INFO: Embed is not available in this context. Will not embed.
RuntimeError: Keyboard is not visible
    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/failure_helpers.rb:75:in `screenshot_and_raise'
    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/keyboard_helpers.rb:89:in `expect_keyboard_visible!'
    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/core.rb:684:in `keyboard_enter_text'
    from /Users/alexwells/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/calabash-cucumber-0.20.0/lib/calabash-cucumber/device_agent.rb:322:in `method_missing'
    from (irb):10
    from /Users/alexwells/.rbenv/versions/2.3.1/bin/irb:11:in `<main>'
calabash-ios 0.20.0> device_agent.enter_text("Hello")
{
    "status" => "success"
}
jmoody commented 8 years ago

@AlexWellsHS

This behavior is expected. Core#keyboard_visible? uses the Calabash iOS Server to check for the keyboard and DeviceAgent#keyboard_visible? uses the DeviceAgent to check for the keyboard. This is analogous to the difference between Core#keyboard_visibile? and uia_keyboard_visible?

It is possible for us to update Core#keyboard_visible? to check for a Remote Keyboard (technically this is what a SafariViewController keyboard is), but there are some performance considerations - the LPServer is fast, but the DeviceAgent is a bit slow and unstable on some views.

I am keeping this issue open because we actively investigating whether it is possible to combine all keyboard checks into one method.

jmoody commented 8 years ago

@jescriba

I think I mentioned this before: we might want to update the Core#keyboard_visible? method to call the Automator keyboard_visible?. We can only do this if DeviceAgent keyboard_visible? does not hang. We might need to introduce a delay in the client before and between calls to keyboard_visible?

I started a branch on calabash-ios: feature/Core-keyboard_visible-calls-automator-keyboard_visible to demonstrate what I think we could do.

skhand001 commented 6 years ago

@jmoody We are facing the same issue. Core#keyboard_visible? returns false. Hence, we are using device_agent.keyboard_visible?. However, it sometimes throws error "Device Agent is not running".

Xcode - 9.2 iOS 11 run_loop - 2.6.2 calabash - 0.21.1