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

Calabash can return the type of the visible keyboard #1207

Merged
merged 4 commits into from Oct 26, 2016
Merged

Conversation

jescriba
Copy link
Contributor

@jescriba jescriba commented Oct 17, 2016

Motivation
Add ability to query keyboard type from a query or first responder.

i.e. keyboard_type("UITextField") => :email

Progress on:

Copy link
Member

@jmoody jmoody left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you decide that you want keyboard_type to raise on unexpected keyboardType results, I think the error message should be improved.

You can also decide not to raise at all, but just log the exceptional cases and return something like :unknown.

Thanks!!!

# UIKeyboardTypeWebSearch => :web_search
#
# @raise [RuntimeError] if there is no visible keyboard
def keyboard_type(query)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to take an argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We basically just need a query to pass into for :keyboardType - an alternative would be to use the first responder instead. Is that more desired behavior?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a keyboard visible, then there should be a first responder.

Have you come across a case where we would need a different query?

if keyboard_type.is_a?(Fixnum)
return KEYBOARD_TYPES[keyboard_type]
else
screenshot_and_raise "Invalid keyboard type"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this raise?

In this case a screenshot would not give enough information to help the user or us understand what went wrong.

The way I can see this failing is:

  1. keyboardType is nil - either there was no first responder (empty results) or for some reason the first element of the results is nil.
  2. keyboardType is "*****" - first responder does not respond to keyboardType.
  3. keyboardType is unknown to us - we don't know about it so it is not one of our KEYBOARD_TYPES
  4. keyboardType is not a Fixnum ^ similar to above

Point 2 above will happen fairly often - I believe the Slack app, for example, is using a UI Text Input class that does not respond to keyboardType. There is an example of this kind of input field in the CalSmokeApp feature/update-to-0.20.3.

If we do raise, I think we should try to provide as much information as possible (capture why we failed).

Maybe we debug log the exceptional cases and return :unknown if we are on the unhappy path?=

query_result = _query_wrapper(query, :keyboardType).first

keyboard_type = KEYBOARD_TYPES[query_result]

if !keyboard_type
  # Assuming we do not raise
  keyboard_type = :unknown
end

keyboard_type

@jmoody jmoody added this to the 0.20.4 milestone Oct 26, 2016
@jmoody jmoody merged commit 4497b3f into develop Oct 26, 2016
@jmoody jmoody deleted the numeric-keyboard branch October 26, 2016 14:51
@jmoody jmoody changed the title Numeric keyboard Calabash can return the type of the visible keyboard Dec 6, 2016
@jmoody jmoody mentioned this pull request Jan 2, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants