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

Wait for elements to be valid before attempting to type in them #229

Conversation

justinseanmartin
Copy link

Wait for elements to be valid before attempting to type in them. I was finding that sometimes the "type" would be failing because an alert window was still the keyWindow when [self hasKeyboardFocus] would attempt to generate an accessibilityPath.

@@ -35,6 +35,9 @@ - (void)setText:(NSString *)text {

- (void)setText:(NSString *)text withKeyboard:(id<SLKeyboard>)keyboard
{
// Need to make sure the element is visible first, because hasKeyboardFocus is a one-shot check
[self waitUntilValidWithTimeout:[SLElement defaultTimeout]];

// Tap to show the keyboard (if the field doesn't already have keyboard focus,
// because in that case a real user would probably not tap again before typing)
if (![self hasKeyboardFocus]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be simpler just to amend this line to read if (![self isValid] || ![self hasKeyboardFocus]) {…. Then we can use tap to wait for validity.

@wearhere
Copy link
Contributor

wearhere commented Jul 8, 2014

Good catch, @justinseanmartin---setText is supposed to wait till the element is valid. Can you fix this in SLWebTextField and SLTextView/SLWebTextView too?

wearhere added a commit that referenced this pull request Jul 9, 2014
…t-before-typing

Wait for elements to be valid before attempting to type in them
@wearhere wearhere merged commit 9f76c3e into inkling:master Jul 9, 2014
@wearhere
Copy link
Contributor

wearhere commented Jul 9, 2014

👍 Thanks!

@justinseanmartin justinseanmartin deleted the jmartin/wait-for-element-before-typing branch July 9, 2014 00:59
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.

2 participants