appium-webdriveragent 5.13.3 → 5.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [5.14.0](https://github.com/appium/WebDriverAgent/compare/v5.13.3...v5.14.0) (2023-11-10)
2
+
3
+
4
+ ### Features
5
+
6
+ * use khidusage_keyboardclear to `clear` for iOS/iPad as the 1st attempt, tune tvOS ([#811](https://github.com/appium/WebDriverAgent/issues/811)) ([dd093ea](https://github.com/appium/WebDriverAgent/commit/dd093ea0b7209c3d2f3d0b1fa7f3a7b58507dd2d))
7
+
1
8
  ## [5.13.3](https://github.com/appium/WebDriverAgent/compare/v5.13.2...v5.13.3) (2023-11-10)
2
9
 
3
10
 
@@ -15,11 +15,12 @@
15
15
  #import "NSString+FBVisualLength.h"
16
16
  #import "FBXCElementSnapshotWrapper.h"
17
17
  #import "FBXCElementSnapshotWrapper+Helpers.h"
18
+ #import "XCUIDevice+FBHelpers.h"
18
19
  #import "XCUIElement+FBCaching.h"
19
20
  #import "XCUIElement+FBUtilities.h"
20
21
  #import "FBXCodeCompatibility.h"
21
22
 
22
- #define MAX_CLEAR_RETRIES 2
23
+ #define MAX_CLEAR_RETRIES 3
23
24
 
24
25
 
25
26
  @interface NSString (FBRepeat)
@@ -136,27 +137,32 @@
136
137
  backspaceDeleteSequence = [[NSString alloc] initWithData:(NSData *)[@"\\u0008\\u007F" dataUsingEncoding:NSASCIIStringEncoding]
137
138
  encoding:NSNonLossyASCIIStringEncoding];
138
139
  });
139
-
140
+
141
+ NSUInteger preClearTextLength = [currentValue fb_visualLength];
142
+ NSString *backspacesToType = [backspaceDeleteSequence fb_repeatTimes:preClearTextLength];
143
+
144
+ #if TARGET_OS_IOS
140
145
  NSUInteger retry = 0;
141
146
  NSString *placeholderValue = snapshot.placeholderValue;
142
- NSUInteger preClearTextLength = [currentValue fb_visualLength];
143
147
  do {
144
- if (retry >= MAX_CLEAR_RETRIES - 1) {
145
- // Last chance retry. Tripple-tap the field to select its content
146
-
147
- if ([self respondsToSelector:@selector(tapWithNumberOfTaps:numberOfTouches:)]) {
148
- // e.g. tvOS 17 raised unrecognized selector error for XCUIElementTypeSearchField
149
- // while following typeText worked.
150
- [self tapWithNumberOfTaps:3 numberOfTouches:1];
151
- }
152
- return [FBKeyboard typeText:backspaceDeleteSequence error:error];
153
- }
154
-
155
- NSString *textToType = [backspaceDeleteSequence fb_repeatTimes:preClearTextLength];
148
+ // the ios needs to have keyboard focus to clear text
156
149
  if (shouldPrepareForInput && 0 == retry) {
157
150
  [self fb_prepareForTextInputWithSnapshot:snapshot];
158
151
  }
159
- if (![FBKeyboard typeText:textToType error:error]) {
152
+
153
+ if (retry == 0) {
154
+ // 1st attempt is via the IOHIDEvent as the fastest operation
155
+ // https://github.com/appium/appium/issues/19389
156
+ [[XCUIDevice sharedDevice] fb_performIOHIDEventWithPage:0x07 // kHIDPage_KeyboardOrKeypad
157
+ usage:0x9c // kHIDUsage_KeyboardClear
158
+ duration:0.01
159
+ error:nil];
160
+ } else if (retry >= MAX_CLEAR_RETRIES - 1) {
161
+ // Last chance retry. Tripple-tap the field to select its content
162
+ [self tapWithNumberOfTaps:3 numberOfTouches:1];
163
+ return [FBKeyboard typeText:backspaceDeleteSequence error:error];
164
+ } else if (![FBKeyboard typeText:backspacesToType error:error]) {
165
+ // 2nd operation
160
166
  return NO;
161
167
  }
162
168
 
@@ -170,6 +176,13 @@
170
176
  retry++;
171
177
  } while (preClearTextLength > 0);
172
178
  return YES;
179
+ #else
180
+ // tvOS does not need a focus.
181
+ // kHIDPage_KeyboardOrKeypad did not work for tvOS's search field. (tvOS 17 at least)
182
+ // Tested XCUIElementTypeSearchField and XCUIElementTypeTextView whch were
183
+ // common search field and email/passowrd input in tvOS apps.
184
+ return [FBKeyboard typeText:backspacesToType error:error];
185
+ #endif
173
186
  }
174
187
 
175
188
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "5.13.3",
3
+ "version": "5.14.0",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {