appium-webdriveragent 4.6.1 → 4.7.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.
@@ -37,12 +37,12 @@
37
37
  - (void)resolveHandleUIInterruption:(BOOL)arg1;
38
38
  - (BOOL)waitForExistenceWithTimeout:(double)arg1;
39
39
  - (BOOL)_waitForExistenceWithTimeout:(double)arg1;
40
+ - (id)_hitPointByAttemptingToScrollToVisibleSnapshot:(id)arg1 error:(id *)arg2;
40
41
  - (BOOL)evaluatePredicateForExpectation:(id)arg1 debugMessage:(id *)arg2;
41
42
  - (void)_swipe:(unsigned long long)arg1;
42
43
  - (void)_tapWithNumberOfTaps:(unsigned long long)arg1 numberOfTouches:(unsigned long long)arg2 activityTitle:(id)arg3;
43
44
  - (id)_highestNonWindowAncestorOfElement:(id)arg1 notSharedWithElement:(id)arg2;
44
45
  - (id)_pointsInFrame:(CGRect)arg1 numberOfTouches:(unsigned long long)arg2;
45
- - (CGPoint)_hitPointByAttemptingToScrollToVisibleSnapshot:(id)arg1;
46
46
  // Since 11.3
47
47
  - (void)pressWithPressure:(double)arg1 duration:(double)arg2;
48
48
  - (void)forcePress;
@@ -60,6 +60,16 @@ typedef NS_ENUM(NSUInteger, FBXCUIElementScrollDirection) {
60
60
  */
61
61
  - (BOOL)fb_scrollToVisibleWithError:(NSError **)error;
62
62
 
63
+ /**
64
+ Scrolls parent scroll view till the current element is visible.
65
+ This call is fast as it uses a native XCTest implementation.
66
+ The element must be hittable.
67
+
68
+ @param error If there is an error, upon return contains an NSError object that describes the problem.
69
+ @return YES if the operation succeeds, otherwise NO.
70
+ */
71
+ - (BOOL)fb_nativeScrollToVisibleWithError:(NSError **)error;
72
+
63
73
  /**
64
74
  Scrolls parent scroll view till receiver is visible. Whenever element is invisible it scrolls by normalizedScrollDistance
65
75
  in its direction. E.g. if normalizedScrollDistance is equal to 0.5, each step will scroll by half of scroll view's size.
@@ -47,6 +47,15 @@ const CGFloat FBScrollTouchProportion = 0.75f;
47
47
 
48
48
  @implementation XCUIElement (FBScrolling)
49
49
 
50
+ - (BOOL)fb_nativeScrollToVisibleWithError:(NSError **)error
51
+ {
52
+ XCElementSnapshot *snapshot = self.fb_isResolvedFromCache.boolValue
53
+ ? self.lastSnapshot
54
+ : self.fb_takeSnapshot;
55
+ return nil != [self _hitPointByAttemptingToScrollToVisibleSnapshot:snapshot
56
+ error:error];
57
+ }
58
+
50
59
  - (void)fb_scrollUpByNormalizedDistance:(CGFloat)distance
51
60
  {
52
61
  XCElementSnapshot *snapshot = self.fb_isResolvedFromCache.boolValue
@@ -84,6 +84,7 @@
84
84
  [[FBRoute POST:@"/wda/element/:uuid/tapWithNumberOfTaps"] respondWithTarget:self action:@selector(handleTapWithNumberOfTaps:)],
85
85
  [[FBRoute POST:@"/wda/element/:uuid/touchAndHold"] respondWithTarget:self action:@selector(handleTouchAndHold:)],
86
86
  [[FBRoute POST:@"/wda/element/:uuid/scroll"] respondWithTarget:self action:@selector(handleScroll:)],
87
+ [[FBRoute POST:@"/wda/element/:uuid/scrollTo"] respondWithTarget:self action:@selector(handleScrollTo:)],
87
88
  [[FBRoute POST:@"/wda/element/:uuid/dragfromtoforduration"] respondWithTarget:self action:@selector(handleDrag:)],
88
89
  [[FBRoute POST:@"/wda/element/:uuid/forceTouch"] respondWithTarget:self action:@selector(handleForceTouch:)],
89
90
  [[FBRoute POST:@"/wda/dragfromtoforduration"] respondWithTarget:self action:@selector(handleDragCoordinate:)],
@@ -383,6 +384,17 @@
383
384
  return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:@"Unsupported scroll type" traceback:nil]);
384
385
  }
385
386
 
387
+ + (id<FBResponsePayload>)handleScrollTo:(FBRouteRequest *)request
388
+ {
389
+ FBElementCache *elementCache = request.session.elementCache;
390
+ XCUIElement *element = [elementCache elementForUUID:(NSString *)request.parameters[@"uuid"]];
391
+ NSError *error;
392
+ return [element fb_nativeScrollToVisibleWithError:&error]
393
+ ? FBResponseWithOK()
394
+ : FBResponseWithStatus([FBCommandStatus invalidElementStateErrorWithMessage:error.description
395
+ traceback:nil]);
396
+ }
397
+
386
398
  + (id<FBResponsePayload>)handleDragCoordinate:(FBRouteRequest *)request
387
399
  {
388
400
  FBSession *session = request.session;
@@ -537,7 +549,8 @@
537
549
  NSError *error;
538
550
  NSData *screenshotData = [element fb_screenshotWithError:&error];
539
551
  if (nil == screenshotData) {
540
- return FBResponseWithStatus([FBCommandStatus unableToCaptureScreenErrorWithMessage:error.description traceback:nil]);
552
+ return FBResponseWithStatus([FBCommandStatus unableToCaptureScreenErrorWithMessage:error.description
553
+ traceback:nil]);
541
554
  }
542
555
  NSString *screenshot = [screenshotData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
543
556
  return FBResponseWithObject(screenshot);
Binary file
@@ -80,6 +80,16 @@
80
80
  FBAssertVisibleCell(cellName);
81
81
  }
82
82
 
83
+ - (void)testNativeFarScrollToVisible
84
+ {
85
+ NSString *cellName = @"80";
86
+ NSError *error;
87
+ FBAssertInvisibleCell(cellName);
88
+ XCTAssertTrue([FBCellElementWithLabel(cellName) fb_nativeScrollToVisibleWithError:&error]);
89
+ XCTAssertNil(error);
90
+ FBAssertVisibleCell(cellName);
91
+ }
92
+
83
93
  - (void)testAttributeWithNullScrollToVisible
84
94
  {
85
95
  NSError *error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "4.6.1",
3
+ "version": "4.7.0",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "build/index.js",
6
6
  "scripts": {