-
Notifications
You must be signed in to change notification settings - Fork 380
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
feat: Add khidusage_keyboardclear as possible option for text field clear on iOS #810
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 |
---|---|---|
|
@@ -15,11 +15,12 @@ | |
#import "NSString+FBVisualLength.h" | ||
#import "FBXCElementSnapshotWrapper.h" | ||
#import "FBXCElementSnapshotWrapper+Helpers.h" | ||
#import "XCUIDevice+FBHelpers.h" | ||
#import "XCUIElement+FBCaching.h" | ||
#import "XCUIElement+FBUtilities.h" | ||
#import "FBXCodeCompatibility.h" | ||
|
||
#define MAX_CLEAR_RETRIES 2 | ||
#define MAX_CLEAR_RETRIES 3 | ||
|
||
|
||
@interface NSString (FBRepeat) | ||
|
@@ -141,24 +142,33 @@ - (BOOL)fb_clearTextWithSnapshot:(FBXCElementSnapshotWrapper *)snapshot | |
NSString *placeholderValue = snapshot.placeholderValue; | ||
NSUInteger preClearTextLength = [currentValue fb_visualLength]; | ||
do { | ||
if (retry >= MAX_CLEAR_RETRIES - 1) { | ||
// Last chance retry. Tripple-tap the field to select its content | ||
|
||
if ([self respondsToSelector:@selector(tapWithNumberOfTaps:numberOfTouches:)]) { | ||
// e.g. tvOS 17 raised unrecognized selector error for XCUIElementTypeSearchField | ||
// while following typeText worked. | ||
[self tapWithNumberOfTaps:3 numberOfTouches:1]; | ||
} | ||
return [FBKeyboard typeText:backspaceDeleteSequence error:error]; | ||
} | ||
|
||
NSString *textToType = [backspaceDeleteSequence fb_repeatTimes:preClearTextLength]; | ||
if (shouldPrepareForInput && 0 == retry) { | ||
[self fb_prepareForTextInputWithSnapshot:snapshot]; | ||
} | ||
if (![FBKeyboard typeText:textToType error:error]) { | ||
NSString *backspacesToType = [backspaceDeleteSequence fb_repeatTimes:preClearTextLength]; | ||
#if TARGET_OS_IOS | ||
if (retry == MAX_CLEAR_RETRIES - 2) { | ||
// https://github.com/appium/appium/issues/19389 | ||
[[XCUIDevice sharedDevice] fb_performIOHIDEventWithPage:0x07 | ||
KazuCocoa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
usage:0x9c | ||
duration:0.05 | ||
error:nil]; | ||
} else if (retry >= MAX_CLEAR_RETRIES - 1) { | ||
// Last chance retry. Tripple-tap the field to select its content | ||
[self tapWithNumberOfTaps:3 numberOfTouches:1]; | ||
return [FBKeyboard typeText:backspaceDeleteSequence error:error]; | ||
} else if (![FBKeyboard typeText:backspacesToType error:error]) { | ||
return NO; | ||
} | ||
#else | ||
if (retry >= MAX_CLEAR_RETRIES - 1) { | ||
return [[[FBErrorBuilder builder] | ||
withDescriptionFormat:@"'%@' cannot be cleared of its text", snapshot.fb_description] | ||
buildError:error]; | ||
} else if (![FBKeyboard typeText:backspacesToType error:error]) { | ||
Comment on lines
+164
to
+168
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. Can we change here to:
?
This was because So, just keeping existing behavior with |
||
return NO; | ||
} | ||
#endif | ||
|
||
currentValue = self.fb_takeSnapshot.value; | ||
if (nil != placeholderValue && [currentValue isEqualToString:placeholderValue]) { | ||
|
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.
so,
1st attempt -> typeText
2nd -> fb_performIOHIDEventWithPage
3rd ->
tapWithNumberOfTaps:3
correct? Or I wondered if we could try the fb_performIOHIDEventWithPage first, then typeText, but the last one will be
tapWithNumberOfTaps:3
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.
What's about #811 ?