Skip to content

Commit f864a39

Browse files
Mykola Mokhnachdpgraham
authored andcommitted
Pick up the recent updates from the Facebook WDA repository (#87)
* Remove TableView scrolling integration tests Summary: We have duplicated scrolling tests for regular tableViews and simple scrollviews. It was usefull to have them, but now testing scrolling on scrollviews covers both cases anyway and we will waste less time testing. Reviewed By: antiarchit Differential Revision: D6543548 fbshipit-source-id: 35e717c43208b8f138a706798d9aa8a9e34b302a * Use fb_tapWithError in alert integration tests Summary: Some alert integration tests are flaky on our CI. I suspect this happens due to failing `tap` command, which might be failing to tap on animated view. This know XCTest issue. Fortunately we have `fb_tapWithError` that handels are common pitfalls. Reviewed By: antiarchit Differential Revision: D6543616 fbshipit-source-id: f12ea7da67058253deff53fa980ebf2e55a93899 * Fix rotation integeation tests Summary: Rather then depending on XCUITest information on orientation, we should test what is application perception Reviewed By: antiarchit Differential Revision: D6543511 fbshipit-source-id: 192e50d0202f96bd6119921c9353a72789b33ad4 * Kill testExtrasIconContent Summary: This test is super device/simulator specific, that was used to interate on visibility improvements. Right now it does not bring much value anyway. Reviewed By: antiarchit Differential Revision: D6543627 fbshipit-source-id: ffbda3b0b5ecde6a632e88030e84fae5af614347 * Use Xcode 9.2 and iOS 11.2 on Travis Summary: It is time to move on. Reviewed By: antiarchit Differential Revision: D6692223 fbshipit-source-id: 81913167551191b2f9e177ff1ead943f6fc25752 * Fix scrolling on big scroll offsets Summary: `XCUICoordinate` seems to have a bug that will return half of offset in case coordinate referance point goes off screen. I suspect this has something to do with retina displays. Instead of using Apple's implementation of `screenPoint` I implemented our own. Reviewed By: antiarchit Differential Revision: D6702218 fbshipit-source-id: b01ef061732281cdf8c6707de38a11b6e31b9c28 * Run testInvisibleDescendantWithXPathQuery test on scroll page Summary: With all visibility changes tested pageindicator is no longer considered invisible. For the time being this is ok with us. This diff uses different invisible elements to run same test of search for invisible elements Reviewed By: antiarchit Differential Revision: D6702252 fbshipit-source-id: a2bd5198d14f05cb1b33afe76a6b5bda7e34a847 * Do not run testSpringBoardIcons on iPads Summary: This test was not intended to run on iPad, so we should turn it off so that we can make Travis green again :). Reviewed By: antiarchit Differential Revision: D6726707 fbshipit-source-id: db92f23b2dc755e7c1464069c04b1838717b8ff4 * Fix resolving XCUIApplication snapshots Summary: With new xcode it looks like, calling `query`, `resolve` on XCUIApplication will in some sense break it. Not sure exactly what goes wrong, but final result is that it's missing some children and description of that object is empty. Instead we can use new API for fetching snapshots for debugging. Reviewed By: lawrencelomax Differential Revision: D6723102 fbshipit-source-id: a33d9caf03eef4450f3879996493493c2cb257b4 * Use visibleFrame to calculate scrolling vector Summary: Using views frame for calculating scroling vector might be buggy when application is doing tricky stuff with scolling views eg. nesting scrollview within scrollview. In that case frame of the second scrollview will be huge and make scrolling imposible as we will try to use points of the screen. Instead we should visible frame. Reviewed By: antiarchit Differential Revision: D6819626 fbshipit-source-id: 27062f593485b4ec55ae8bd1a9c9a32a89630b92 * fb_isVisible using interfaceOrientation instead of Device orientation. Summary: [XCUIDevice sharedDevice].orientation may get values like FaceUp, which cause wrong calculation of the app frame size, in landscape. With devices in Lab, standing portrait, this problem is less common. Working on development with devices on the table it happens more often causing a great deal of confusion. From my tests, using app interfaceOrientation gives always the reality of the App. Closes facebookarchive/WebDriverAgent#875 Reviewed By: marekcirkos Differential Revision: D7067153 Pulled By: antiarchit fbshipit-source-id: c6aa8f8823d0f43e5072a190c34df931d0d6b8b8 * Fix testIconsFromSearchDashboard integration test Summary: It might be there is more than one `IntegrationApp` icon on the dashboard while integration tests are running on Travis. Addresses https://travis-ci.org/facebook/WebDriverAgent/jobs/349725814 Closes facebookarchive/WebDriverAgent#883 Differential Revision: D7289614 Pulled By: marekcirkos fbshipit-source-id: e5060888f2a752c039fcf815984e24579a3cef06 * Allow to override typing frequency for single typing request Reviewed By: antiarchit Differential Revision: D7615943 fbshipit-source-id: 9cb82dce23c02970d0c29613c7de4ebca0838361 * Include RoutingHTTPServer in copy to fix ISSUE #902 Summary: Include RoutingHTTPServer in copy to fix ISSUE #902 Closes facebookarchive/WebDriverAgent#915 Differential Revision: D7947944 Pulled By: marekcirkos fbshipit-source-id: ca60238fc3f715f753f084493aec5afa4524b21b * Fix the incorrect tap coordinate in landscape mode. Summary: If SDK >= 11, the tap coordinate based on application is not correct when the application orientation is landscape and tapX > application portrait width or tapY > application portrait height. Pass the window element to the method [FBElementCommands gestureCoordinateWithCoordinate:element:] will resolve the problem. More details about the bug, please see the following issues: #705, #798, #856. Notice: On iOS 10, if the application is not launched by wda, no elements will be found. See issue #732. Closes facebookarchive/WebDriverAgent#878 Differential Revision: D7947931 Pulled By: marekcirkos fbshipit-source-id: 4f8ef1484761b79c69f67df40293eea70bc08984 * Update flow-bin for WebDriverAgent's Inspector Differential Revision: D8220228 fbshipit-source-id: cf08317ab2e50282373576fedb7c2b26b47969ad * Handle infinitive numbers in elements rect Summary: In case testmanagerd has problems in calculating frames it may return 'inf' instead which does not behave well with JSON encoding. Therfore checing for infs when formating JSON reponse Reviewed By: antiarchit Differential Revision: D7067158 fbshipit-source-id: 180400186af49f1353d93e9eb61d7306b8a1a0f6 * force touch support Summary: A couple of commands which make possible to force touch given element or point by coordinates. In fact – copy of the tap extension. Baked with integration tests. Updated with mykola-mokhnach improvements in appium#79 Closes facebookarchive/WebDriverAgent#917 Differential Revision: D8220249 Pulled By: marekcirkos fbshipit-source-id: 2a14ab5759894577a1f5e40f20b4a6d79e519419 * Support getting the element cache size, clearing the element cache Summary: Every time a user finds an element using the `element` or `elements` route, a new `XCUIElement` object is added to the session cache. The elements are never removed from the cache. A very naïve script which goes to the home screen and queries for the 'Phone' element 1000 times in a row, will cause memory consumption (as measured by Xcode) of the WebDriverAgent to grow to approximately 126 MB. Net, it appears that every `XCUIElement` object consumes about 100KB of memory. For sessions which persist for a long period of time (say, 30 minutes or more), this can eventually lead to an out of memory situation in which the WebDriverAgent crashes. This PR tries to provide an 'escape hatch' for applications which want long-running sessions, by allowing them to: - query the amount of elements in the cache - clear the element cache by adding two custom routes. We're looking at other approaches to keep the cache size under control as well - e.g. by checking the element cache for duplicates and adding an option to remove 'stale' elements (elements which no longer exist); we'll try to submit PRs for that as well. As usual, let me know what you think & happy to discuss further. Closes facebookarchive/WebDriverAgent#896 Differential Revision: D8254682 Pulled By: marekcirkos fbshipit-source-id: a200a570d9b4e71a6f2171419b39126dd9affca3 * Fix fb_framelessFuzzyMatchesElement method Summary: In XCUIElementTypeTable,attribute values of many XCUIElementTypeCell instances are null.When fb_scrollToVisibleWithNormalizedScrollDistance function is called by XCUIElementTypeCell instance,it is unable to accurately slide the specified UI element. Closes facebookarchive/WebDriverAgent#879 Differential Revision: D8255752 Pulled By: marekcirkos fbshipit-source-id: 930f478417823ae0c0f79d1699d61af616f3c781 * Tune nullability * comment out flaky tests * Optimize force touch endpoint
1 parent eec92e5 commit f864a39

File tree

16 files changed

+313
-30
lines changed

16 files changed

+313
-30
lines changed

packages/webdriveragent/Inspector/.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe
1111
esproposal.class_static_fields=enable
1212

1313
[version]
14-
^0.46.0
14+
^0.73.0

packages/webdriveragent/Inspector/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"eslint-plugin-babel": "^4.0.1",
2626
"eslint-plugin-flowtype": "^2.30.0",
2727
"eslint-plugin-react": "^6.9.0",
28-
"flow-bin": "^0.46.0",
28+
"flow-bin": "^0.73.0",
2929
"webpack-dev-server": "^1.10.1"
3030
},
3131
"scripts": {

packages/webdriveragent/WebDriverAgent.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@
302302
EE7E271E1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = EE7E271A1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.h */; };
303303
EE7E271F1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = EE7E271B1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.m */; };
304304
EE8BA97A1DCCED9A00A9DEF8 /* FBNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = EE8BA9791DCCED9A00A9DEF8 /* FBNavigationController.m */; };
305+
EE8DDD7B20C57320004D4925 /* FBForceTouchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = EE8DDD7A20C57320004D4925 /* FBForceTouchTests.m */; };
306+
EE8DDD7E20C5733C004D4925 /* XCUIElement+FBForceTouch.m in Sources */ = {isa = PBXBuildFile; fileRef = EE8DDD7C20C5733B004D4925 /* XCUIElement+FBForceTouch.m */; };
307+
EE8DDD7F20C5733C004D4925 /* XCUIElement+FBForceTouch.h in Headers */ = {isa = PBXBuildFile; fileRef = EE8DDD7D20C5733C004D4925 /* XCUIElement+FBForceTouch.h */; settings = {ATTRIBUTES = (Public, ); }; };
305308
EE9AB8011CAEE048008C271F /* UITestingUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9AB7FD1CAEE048008C271F /* UITestingUITests.m */; };
306309
EE9B76591CF7987800275851 /* FBRouteTests.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9B76571CF7987300275851 /* FBRouteTests.m */; };
307310
EE9B768E1CF7997600275851 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9B76831CF7997600275851 /* AppDelegate.m */; };
@@ -656,6 +659,9 @@
656659
EE836C021C0F118600D87246 /* UnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
657660
EE8BA9781DCCED9A00A9DEF8 /* FBNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBNavigationController.h; sourceTree = "<group>"; };
658661
EE8BA9791DCCED9A00A9DEF8 /* FBNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBNavigationController.m; sourceTree = "<group>"; };
662+
EE8DDD7A20C57320004D4925 /* FBForceTouchTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBForceTouchTests.m; sourceTree = "<group>"; };
663+
EE8DDD7C20C5733B004D4925 /* XCUIElement+FBForceTouch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "XCUIElement+FBForceTouch.m"; sourceTree = "<group>"; };
664+
EE8DDD7D20C5733C004D4925 /* XCUIElement+FBForceTouch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XCUIElement+FBForceTouch.h"; sourceTree = "<group>"; };
659665
EE9AB7451CAEDF0C008C271F /* XCUIElement+FBAccessibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XCUIElement+FBAccessibility.h"; sourceTree = "<group>"; };
660666
EE9AB7461CAEDF0C008C271F /* XCUIElement+FBAccessibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "XCUIElement+FBAccessibility.m"; sourceTree = "<group>"; };
661667
EE9AB7471CAEDF0C008C271F /* XCUIElement+FBIsVisible.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XCUIElement+FBIsVisible.h"; sourceTree = "<group>"; };
@@ -955,6 +961,8 @@
955961
71A7EAF41E20516B001DA4F2 /* XCUIElement+FBClassChain.m */,
956962
EEBBD4891D47746D00656A81 /* XCUIElement+FBFind.h */,
957963
EEBBD48A1D47746D00656A81 /* XCUIElement+FBFind.m */,
964+
EE8DDD7D20C5733C004D4925 /* XCUIElement+FBForceTouch.h */,
965+
EE8DDD7C20C5733B004D4925 /* XCUIElement+FBForceTouch.m */,
958966
EE9AB7471CAEDF0C008C271F /* XCUIElement+FBIsVisible.h */,
959967
EE9AB7481CAEDF0C008C271F /* XCUIElement+FBIsVisible.m */,
960968
7136A4771E8918E60024FC3D /* XCUIElement+FBPickerWheel.h */,
@@ -1131,6 +1139,7 @@
11311139
71AB82B11FDAE8C000D1D7C3 /* FBElementScreenshotTests.m */,
11321140
EE006EAC1EB99B15006900A4 /* FBElementVisibilityTests.m */,
11331141
EE6A89361D0B35920083E92B /* FBFailureProofTestCaseTests.m */,
1142+
EE8DDD7A20C57320004D4925 /* FBForceTouchTests.m */,
11341143
EE1E06DB1D18090F007CF043 /* FBIntegrationTestCase.h */,
11351144
EE1E06D91D1808C2007CF043 /* FBIntegrationTestCase.m */,
11361145
EE05BAF91D13003C00A3EB00 /* FBKeyboardTests.m */,
@@ -1481,6 +1490,7 @@
14811490
711084441DA3AA7500F913D6 /* FBXPath.h in Headers */,
14821491
EE35AD771E3B77D600A02D78 /* XCUIRecorderTimingMessage.h in Headers */,
14831492
EE35AD271E3B77D600A02D78 /* XCApplicationMonitor.h in Headers */,
1493+
EE8DDD7F20C5733C004D4925 /* XCUIElement+FBForceTouch.h in Headers */,
14841494
EE158AEA1CBD456F00A3E3F0 /* FBRuntimeUtils.h in Headers */,
14851495
7136A4791E8918E60024FC3D /* XCUIElement+FBPickerWheel.h in Headers */,
14861496
EE35AD511E3B77D600A02D78 /* XCTestObservation-Protocol.h in Headers */,
@@ -1845,6 +1855,7 @@
18451855
EE158AD91CBD456F00A3E3F0 /* FBResponseFilePayload.m in Sources */,
18461856
7140974E1FAE20EE008FB2C5 /* FBBaseActionsSynthesizer.m in Sources */,
18471857
EEE3764A1D59FAE900ED88DD /* XCUIElement+FBWebDriverAttributes.m in Sources */,
1858+
EE8DDD7E20C5733C004D4925 /* XCUIElement+FBForceTouch.m in Sources */,
18481859
71241D7C1FAE3D2500B9559F /* FBTouchActionCommands.m in Sources */,
18491860
EE158ACB1CBD456F00A3E3F0 /* FBTouchIDCommands.m in Sources */,
18501861
EE158ABD1CBD456F00A3E3F0 /* FBDebugCommands.m in Sources */,
@@ -1896,6 +1907,7 @@
18961907
719A97AC1F88E7370063B4BD /* FBAppiumMultiTouchActionsIntegrationTests.m in Sources */,
18971908
715AFAC41FFA2AAF0053896D /* FBScreenTests.m in Sources */,
18981909
EE22021E1ECC618900A29571 /* FBTapTest.m in Sources */,
1910+
EE8DDD7B20C57320004D4925 /* FBForceTouchTests.m in Sources */,
18991911
71930C472066434000D3AFEC /* FBPasteboardTests.m in Sources */,
19001912
71AB82B21FDAE8C000D1D7C3 /* FBElementScreenshotTests.m in Sources */,
19011913
);

packages/webdriveragent/WebDriverAgentLib/Categories/XCElementSnapshot+FBHelpers.m

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#import "XCUIElement.h"
1919
#import "XCUIElement+FBWebDriverAttributes.h"
2020

21-
inline static BOOL valuesAreEqual(id value1, id value2);
2221
inline static BOOL isSnapshotTypeAmongstGivenTypes(XCElementSnapshot* snapshot, NSArray<NSNumber *> *types);
2322

2423
@implementation XCElementSnapshot (FBHelpers)
@@ -60,12 +59,7 @@ - (id)fb_attributeValue:(NSNumber *)attribute
6059

6160
- (BOOL)fb_framelessFuzzyMatchesElement:(XCElementSnapshot *)snapshot
6261
{
63-
return self.elementType == snapshot.elementType &&
64-
valuesAreEqual(self.identifier, snapshot.identifier) &&
65-
valuesAreEqual(self.title, snapshot.title) &&
66-
valuesAreEqual(self.label, snapshot.label) &&
67-
valuesAreEqual(self.value, snapshot.value) &&
68-
valuesAreEqual(self.placeholderValue, snapshot.placeholderValue);
62+
return [self.wdUID isEqualToString:snapshot.wdUID];
6963
}
7064

7165
- (NSArray<XCElementSnapshot *> *)fb_descendantsCellSnapshots
@@ -111,11 +105,6 @@ - (XCElementSnapshot *)fb_parentCellSnapshot
111105
}
112106
@end
113107

114-
inline static BOOL valuesAreEqual(id value1, id value2)
115-
{
116-
return value1 == value2 || [value1 isEqual:value2];
117-
}
118-
119108
inline static BOOL isSnapshotTypeAmongstGivenTypes(XCElementSnapshot* snapshot, NSArray<NSNumber *> *types)
120109
{
121110
for (NSUInteger i = 0; i < types.count; i++) {

packages/webdriveragent/WebDriverAgentLib/Categories/XCUIApplication+FBTouchAction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
5050
@param error If there is an error, upon return contains an NSError object that describes the problem
5151
@return YES If the touch action has been successfully performed without errors
5252
*/
53-
- (BOOL)fb_performAppiumTouchActions:(NSArray *)actions elementCache:(nullable FBElementCache *)elementCache error:(NSError **)error;
53+
- (BOOL)fb_performAppiumTouchActions:(NSArray *)actions elementCache:(nullable FBElementCache *)elementCache error:(NSError * _Nullable*)error;
5454

5555
/**
5656
Perform complex touch action in scope of the current application.
@@ -60,7 +60,7 @@ NS_ASSUME_NONNULL_BEGIN
6060
@param error If there is an error, upon return contains an NSError object that describes the problem
6161
@return YES If the touch action has been successfully performed without errors
6262
*/
63-
- (BOOL)fb_performW3CTouchActions:(NSArray *)actions elementCache:(nullable FBElementCache *)elementCache error:(NSError **)error;
63+
- (BOOL)fb_performW3CTouchActions:(NSArray *)actions elementCache:(nullable FBElementCache *)elementCache error:(NSError * _Nullable*)error;
6464

6565
@end
6666

packages/webdriveragent/WebDriverAgentLib/Categories/XCUIApplication+FBTouchAction.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
@implementation XCUIApplication (FBTouchAction)
2222

23-
- (BOOL)fb_performActionsWithSynthesizerType:(Class)synthesizerType actions:(NSArray *)actions elementCache:(nullable FBElementCache *)elementCache error:(NSError **)error
23+
- (BOOL)fb_performActionsWithSynthesizerType:(Class)synthesizerType actions:(NSArray *)actions elementCache:(FBElementCache *)elementCache error:(NSError **)error
2424
{
2525
FBBaseActionsSynthesizer *synthesizer = [[synthesizerType alloc] initWithActions:actions forApplication:self elementCache:elementCache error:error];
2626
if (nil == synthesizer) {
@@ -33,12 +33,12 @@ - (BOOL)fb_performActionsWithSynthesizerType:(Class)synthesizerType actions:(NSA
3333
return [self fb_synthesizeEvent:eventRecord error:error];
3434
}
3535

36-
- (BOOL)fb_performAppiumTouchActions:(NSArray *)actions elementCache:(nullable FBElementCache *)elementCache error:(NSError **)error
36+
- (BOOL)fb_performAppiumTouchActions:(NSArray *)actions elementCache:(FBElementCache *)elementCache error:(NSError **)error
3737
{
3838
return [self fb_performActionsWithSynthesizerType:FBAppiumActionsSynthesizer.class actions:actions elementCache:elementCache error:error];
3939
}
4040

41-
- (BOOL)fb_performW3CTouchActions:(NSArray *)actions elementCache:(nullable FBElementCache *)elementCache error:(NSError **)error
41+
- (BOOL)fb_performW3CTouchActions:(NSArray *)actions elementCache:(FBElementCache *)elementCache error:(NSError **)error
4242
{
4343
return [self fb_performActionsWithSynthesizerType:FBW3CActionsSynthesizer.class actions:actions elementCache:elementCache error:error];
4444
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import <WebDriverAgentLib/XCUIElement.h>
11+
12+
NS_ASSUME_NONNULL_BEGIN
13+
14+
@interface XCUIElement (FBForceTouch)
15+
16+
/**
17+
Waits for element to become stable (not move) and performs sync force touch on element
18+
19+
@param error If there is an error, upon return contains an NSError object that describes the problem.
20+
@param pressure The pressure of the force touch – valid values are [0, touch.maximumPossibleForce]
21+
@param duration The duration of the gesture in float seconds
22+
@return YES if the operation succeeds, otherwise NO.
23+
*/
24+
- (BOOL)fb_forceTouchWithPressure:(double)pressure duration:(double)duration error:(NSError **)error;
25+
26+
/**
27+
Waits for element to become stable (not move) and performs sync force touch on element
28+
29+
@param relativeCoordinate hit point coordinate relative to the current element position
30+
@param pressure The pressure of the force touch – valid values are [0, touch.maximumPossibleForce]
31+
@param duration The duration of the gesture in float seconds
32+
@param error If there is an error, upon return contains an NSError object that describes the problem.
33+
@return YES if the operation succeeds, otherwise NO.
34+
*/
35+
- (BOOL)fb_forceTouchCoordinate:(CGPoint)relativeCoordinate pressure:(double)pressure duration:(double)duration error:(NSError **)error;
36+
37+
@end
38+
39+
NS_ASSUME_NONNULL_END
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import "XCUIElement+FBForceTouch.h"
11+
12+
#import "XCUIApplication+FBTouchAction.m"
13+
14+
@implementation XCUIElement (FBForceTouch)
15+
16+
- (BOOL)fb_forceTouchWithPressure:(double)pressure duration:(double)duration error:(NSError **)error
17+
{
18+
NSArray<NSDictionary<NSString *, id> *> *gesture =
19+
@[@{
20+
@"action": @"press",
21+
@"options": @{
22+
@"element": self,
23+
@"pressure": @(pressure)
24+
}
25+
},
26+
@{
27+
@"action": @"wait",
28+
@"options": @{
29+
@"ms": @(duration * 1000)
30+
}
31+
},
32+
@{
33+
@"action": @"release"
34+
}
35+
];
36+
return [self.application fb_performAppiumTouchActions:gesture elementCache:nil error:error];
37+
}
38+
39+
- (BOOL)fb_forceTouchCoordinate:(CGPoint)relativeCoordinate pressure:(double)pressure duration:(double)duration error:(NSError **)error
40+
{
41+
NSArray<NSDictionary<NSString *, id> *> *gesture =
42+
@[@{
43+
@"action": @"press",
44+
@"options": @{
45+
@"element": self,
46+
@"x": @(relativeCoordinate.x),
47+
@"y": @(relativeCoordinate.y),
48+
@"pressure": @(pressure)
49+
}
50+
},
51+
@{
52+
@"action": @"wait",
53+
@"options": @{
54+
@"ms": @(duration * 1000)
55+
}
56+
},
57+
@{
58+
@"action": @"release"
59+
}
60+
];
61+
return [self.application fb_performAppiumTouchActions:gesture elementCache:nil error:error];
62+
}
63+
64+
@end

packages/webdriveragent/WebDriverAgentLib/Categories/XCUIElement+FBTyping.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ NS_ASSUME_NONNULL_BEGIN
2323
*/
2424
- (BOOL)fb_typeText:(NSString *)text error:(NSError **)error;
2525

26+
/**
27+
Types a text into element.
28+
It will try to activate keyboard on element, if element has no keyboard focus.
29+
30+
@param text text that should be typed
31+
@param frequency Frequency of typing (letters per sec)
32+
@param error If there is an error, upon return contains an NSError object that describes the problem.
33+
@return YES if the operation succeeds, otherwise NO.
34+
*/
35+
- (BOOL)fb_typeText:(NSString *)text frequency:(NSUInteger)frequency error:(NSError **)error;
36+
2637
/**
2738
Clears text on element.
2839
It will try to activate keyboard on element, if element has no keyboard focus.

packages/webdriveragent/WebDriverAgentLib/Categories/XCUIElement+FBTyping.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#import "XCUIElement+FBTyping.h"
1111

12+
#import "FBConfiguration.h"
1213
#import "FBErrorBuilder.h"
1314
#import "FBKeyboard.h"
1415
#import "NSString+FBVisualLength.h"
@@ -41,12 +42,16 @@ - (BOOL)fb_prepareForTextInputWithError:(NSError **)error
4142
}
4243

4344
- (BOOL)fb_typeText:(NSString *)text error:(NSError **)error
45+
{
46+
return [self fb_typeText:text frequency:[FBConfiguration maxTypingFrequency] error:error];
47+
}
48+
49+
- (BOOL)fb_typeText:(NSString *)text frequency:(NSUInteger)frequency error:(NSError **)error
4450
{
4551
if (![self fb_prepareForTextInputWithError:error]) {
4652
return NO;
4753
}
48-
49-
if (![FBKeyboard typeText:text error:error]) {
54+
if (![FBKeyboard typeText:text frequency:frequency error:error]) {
5055
return NO;
5156
}
5257
return YES;

0 commit comments

Comments
 (0)