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
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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:
- keyboardType is nil - either there was no first responder (empty results) or for some reason the first element of the results is
nil
. - keyboardType is "*****" - first responder does not respond to
keyboardType
. - keyboardType is unknown to us - we don't know about it so it is not one of our KEYBOARD_TYPES
- 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
… while returning :unknown
Motivation
Add ability to query keyboard type from a query or first responder.
i.e. keyboard_type("UITextField") => :email
Progress on: