-
Notifications
You must be signed in to change notification settings - Fork 218
Fix/3051 enter text on ios doesnt work with specific selectors #3053
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import 'common.dart'; | ||
|
|
||
| void main() { | ||
| patrol('enterText works with elementType selectors on iOS', ($) async { | ||
| await createApp($); | ||
|
|
||
| await $('Open webview (Hacker News)').scrollTo().tap(); | ||
|
|
||
| await $.pump(Duration(seconds: 5)); | ||
|
|
||
| await $.platform.mobile.tap(Selector(text: 'login')); | ||
| await $.platform.ios.enterText( | ||
| IOSSelector(elementType: IOSElementType.textField), | ||
| text: 'test@leancode.pl', | ||
| keyboardBehavior: KeyboardBehavior.showAndDismiss, | ||
| ); | ||
| await $.platform.ios.enterText( | ||
| IOSSelector(elementType: IOSElementType.secureTextField), | ||
| text: 'ny4ncat', | ||
| keyboardBehavior: KeyboardBehavior.showAndDismiss, | ||
| ); | ||
| }, tags: ['webview', 'ios']); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -153,17 +153,19 @@ | |||||||||||||||||||||||||
| // See: | ||||||||||||||||||||||||||
| // * https://developer.apple.com/documentation/xctest/xcuielementtype/xcuielementtypetextfield | ||||||||||||||||||||||||||
| // * https://developer.apple.com/documentation/xctest/xcuielementtype/xcuielementtypesecuretextfield | ||||||||||||||||||||||||||
| let contentPredicate = selector.toTextFieldNSPredicate() | ||||||||||||||||||||||||||
| let textFieldPredicate = NSPredicate(format: "elementType == 49") | ||||||||||||||||||||||||||
| let secureTextFieldPredicate = NSPredicate(format: "elementType == 50") | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| let finalPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [ | ||||||||||||||||||||||||||
| contentPredicate, | ||||||||||||||||||||||||||
| NSCompoundPredicate(orPredicateWithSubpredicates: [ | ||||||||||||||||||||||||||
| textFieldPredicate, secureTextFieldPredicate, | ||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||
| ]) | ||||||||||||||||||||||||||
| var subpredicates: [NSPredicate] = [NSCompoundPredicate(orPredicateWithSubpredicates: [ | ||||||||||||||||||||||||||
| textFieldPredicate, secureTextFieldPredicate, | ||||||||||||||||||||||||||
| ])] | ||||||||||||||||||||||||||
|
Comment on lines
+159
to
+161
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current implementation ignores the specific
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // toTextFieldNSPredicate() can be nil - depending on the selector user provided | ||||||||||||||||||||||||||
| if let contentPredicate = selector.toTextFieldNSPredicate() { | ||||||||||||||||||||||||||
| subpredicates.insert(contentPredicate, at: 0) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| let finalPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: subpredicates) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| let query = app.descendants(matching: .any).matching(finalPredicate) | ||||||||||||||||||||||||||
| guard | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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.
Can you add comment explaining why?