Skip to content

Commit 87a0321

Browse files
authored
Merge pull request #227 from AirtestProject/feature/appium
更新支持15.4
2 parents b53e265 + 59d6cb1 commit 87a0321

39 files changed

+463
-927
lines changed

WebDriverAgent.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@
340340
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.WebDriverAgentRunner;
341341
PRODUCT_NAME = "$(TARGET_NAME)";
342342
USES_XCTRUNNER = YES;
343+
VALIDATE_WORKSPACE = YES;
343344
};
344345
name = Debug;
345346
};
@@ -364,6 +365,7 @@
364365
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.WebDriverAgentRunner;
365366
PRODUCT_NAME = "$(TARGET_NAME)";
366367
USES_XCTRUNNER = YES;
368+
VALIDATE_WORKSPACE = YES;
367369
};
368370
name = Release;
369371
};

WebDriverAgentLib/WebDriverAgentLib.framework/Headers/CDStructures.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ typedef struct {
2323
unsigned short _field2;
2424
unsigned short _field3[1];
2525
} CDStruct_27a325c0;
26+
27+
int _XCTSetApplicationStateTimeout(double timeout);
28+
double _XCTApplicationStateTimeout(void);

WebDriverAgentLib/WebDriverAgentLib.framework/Headers/FBApplication.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,22 @@ NS_ASSUME_NONNULL_BEGIN
2727
+ (instancetype)fb_activeApplicationWithDefaultBundleId:(nullable NSString *)bundleId;
2828

2929
/**
30-
Constructor used to get the system application
30+
Constructor used to get the system application (e.g. Springboard on iOS)
3131
*/
3232
+ (instancetype)fb_systemApplication;
3333

3434
/**
35-
It allows to turn on/off waiting for application quiescence, while performing queries. Defaults to NO.
35+
Retrieves the list of all currently active applications
3636
*/
37-
@property (nonatomic, assign) BOOL fb_shouldWaitForQuiescence;
37+
+ (NSArray<FBApplication *> *)fb_activeApplications;
38+
39+
/**
40+
Switch to system app (called Springboard on iOS)
41+
42+
@param error If there is an error, upon return contains an NSError object that describes the problem.
43+
@return YES if the operation succeeds, otherwise NO.
44+
*/
45+
+ (BOOL)fb_switchToSystemApplicationWithError:(NSError **)error;
3846

3947
@end
4048

WebDriverAgentLib/WebDriverAgentLib.framework/Headers/FBConfiguration.h

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99

1010
#import <Foundation/Foundation.h>
1111

12-
//#import "AXSettings.h"
13-
//#import "UIKeyboardImpl.h"
14-
//#import "TIPreferencesController.h"
12+
// #import "AXSettings.h"
13+
// #import "UIKeyboardImpl.h"
14+
// #import "TIPreferencesController.h"
1515

1616
NS_ASSUME_NONNULL_BEGIN
1717

18+
extern NSString *const FBSnapshotMaxDepthKey;
19+
1820
/**
1921
Accessors for Global Constants.
2022
*/
@@ -28,16 +30,29 @@ NS_ASSUME_NONNULL_BEGIN
2830
+ (void)setShouldUseCompactResponses:(BOOL)value;
2931
+ (BOOL)shouldUseCompactResponses;
3032

33+
/*! If set to YES (which is the default), the app will be terminated at the end of the session, if a bundleId was specified */
34+
+ (void)setShouldTerminateApp:(BOOL)value;
35+
+ (BOOL)shouldTerminateApp;
36+
3137
/*! If shouldUseCompactResponses == NO, is the comma-separated list of fields to return with each element. Defaults to "type,label". */
3238
+ (void)setElementResponseAttributes:(NSString *)value;
3339
+ (NSString *)elementResponseAttributes;
3440

3541
/*! Disables remote query evaluation making Xcode 9.x tests behave same as Xcode 8.x test */
3642
+ (void)disableRemoteQueryEvaluation;
3743

44+
/*! Enables the extended XCTest debug logging. Useful for developemnt purposes */
45+
+ (void)enableXcTestDebugLogs;
46+
3847
/*! Disables attribute key path analysis, which will cause XCTest on Xcode 9.x to ignore some elements */
3948
+ (void)disableAttributeKeyPathAnalysis;
4049

50+
/*! Disables XCTest automated screenshots taking */
51+
+ (void)disableScreenshots;
52+
53+
/*! Enables XCTest automated screenshots taking */
54+
+ (void)enableScreenshots;
55+
4156
/* The maximum typing frequency for all typing activities */
4257
+ (void)setMaxTypingFrequency:(NSUInteger)value;
4358
+ (NSUInteger)maxTypingFrequency;
@@ -46,10 +61,6 @@ NS_ASSUME_NONNULL_BEGIN
4661
+ (void)setShouldUseSingletonTestManager:(BOOL)value;
4762
+ (BOOL)shouldUseSingletonTestManager;
4863

49-
/* Whether to wait for quiescence on application startup */
50-
+ (void)setShouldWaitForQuiescence:(BOOL)value;
51-
+ (BOOL)shouldWaitForQuiescence;
52-
5364
/**
5465
* Extract switch value from arguments
5566
*
@@ -107,36 +118,54 @@ NS_ASSUME_NONNULL_BEGIN
107118
*/
108119
+ (BOOL)verboseLoggingEnabled;
109120

110-
+ (BOOL)shouldLoadSnapshotWithAttributes;
121+
/**
122+
Disables automatic handling of XCTest UI interruptions.
123+
*/
124+
+ (void)disableApplicationUIInterruptionsHandling;
111125

112126
/**
113127
* Configure keyboards preference to make test running stable
114128
*/
115129
+ (void)configureDefaultKeyboardPreferences;
116130

131+
132+
/**
133+
* Turn on softwar keyboard forcefully for simulator.
134+
*/
135+
+ (void)forceSimulatorSoftwareKeyboardPresence;
136+
137+
/**
138+
Defines keyboard preference enabled status
139+
*/
140+
typedef NS_ENUM(NSInteger, FBConfigurationKeyboardPreference) {
141+
FBConfigurationKeyboardPreferenceDisabled = 0,
142+
FBConfigurationKeyboardPreferenceEnabled = 1,
143+
FBConfigurationKeyboardPreferenceNotSupported = 2,
144+
};
145+
117146
/**
118147
* Modify keyboard configuration of 'auto-correction'.
119148
*
120149
* @param isEnabled Turn the configuration on if the value is YES
121150
*/
122151
+ (void)setKeyboardAutocorrection:(BOOL)isEnabled;
123-
+ (BOOL)keyboardAutocorrection;
152+
+ (FBConfigurationKeyboardPreference)keyboardAutocorrection;
124153

125154
/**
126155
* Modify keyboard configuration of 'predictive'
127156
*
128157
* @param isEnabled Turn the configuration on if the value is YES
129158
*/
130159
+ (void)setKeyboardPrediction:(BOOL)isEnabled;
131-
+ (BOOL)keyboardPrediction;
160+
+ (FBConfigurationKeyboardPreference)keyboardPrediction;
132161

133162
/**
134163
* The maximum time to wait until accessibility snapshot is taken
135164
*
136165
* @param timeout The number of float seconds to wait (15 seconds by default)
137166
*/
138-
+ (void)setSnapshotTimeout:(NSTimeInterval)timeout;
139-
+ (NSTimeInterval)snapshotTimeout;
167+
+ (void)setCustomSnapshotTimeout:(NSTimeInterval)timeout;
168+
+ (NSTimeInterval)customSnapshotTimeout;
140169

141170
/**
142171
Sets maximum depth for traversing elements tree from parents to children while requesting XCElementSnapshot.
@@ -171,6 +200,17 @@ NS_ASSUME_NONNULL_BEGIN
171200
+ (void)setUseFirstMatch:(BOOL)enabled;
172201
+ (BOOL)useFirstMatch;
173202

203+
/**
204+
* Whether to bound the lookup results by index.
205+
* By default this is disabled and bounding by accessibility is used.
206+
* Read https://stackoverflow.com/questions/49307513/meaning-of-allelementsboundbyaccessibilityelement
207+
* for more details on these two bounding methods.
208+
*
209+
* @param enabled Either YES or NO
210+
*/
211+
+ (void)setBoundElementsByIndex:(BOOL)enabled;
212+
+ (BOOL)boundElementsByIndex;
213+
174214
/**
175215
* Modify reduce motion configuration in accessibility.
176216
* It works only for Simulator since Real device has security model which allows chnaging preferences
@@ -181,6 +221,28 @@ NS_ASSUME_NONNULL_BEGIN
181221
+ (void)setReduceMotionEnabled:(BOOL)isEnabled;
182222
+ (BOOL)reduceMotionEnabled;
183223

224+
/**
225+
* Set the idling timeout. If the timeout expires then WDA
226+
* tries to interact with the application even if it is not idling.
227+
* Setting it to zero disables idling checks.
228+
* The default timeout is set to 10 seconds.
229+
*
230+
* @param timeout The actual timeout value in float seconds
231+
*/
232+
+ (void)setWaitForIdleTimeout:(NSTimeInterval)timeout;
233+
+ (NSTimeInterval)waitForIdleTimeout;
234+
235+
/**
236+
* Set the idling timeout for different actions, for example events synthesis, rotation change,
237+
* etc. If the timeout expires then WDA tries to interact with the application even if it is not idling.
238+
* Setting it to zero disables idling checks.
239+
* The default timeout is set to 2 seconds.
240+
*
241+
* @param timeout The actual timeout value in float seconds
242+
*/
243+
+ (void)setAnimationCoolOffTimeout:(NSTimeInterval)timeout;
244+
+ (NSTimeInterval)animationCoolOffTimeout;
245+
184246
/**
185247
Enforces the page hierarchy to include non modal elements,
186248
like Contacts. By default such elements are not present there.

WebDriverAgentLib/WebDriverAgentLib.framework/Headers/FBElement.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ NS_ASSUME_NONNULL_BEGIN
1717
*/
1818
@protocol FBElement <NSObject>
1919

20-
/*! Element's frame in CGRect format */
20+
/*! Element's frame in normalized (rounded dimensions without Infinity values) CGRect format */
2121
@property (nonatomic, readonly, assign) CGRect wdFrame;
2222

23-
/*! Element's frame in NSDictionary format */
23+
/*! Element's wsFrame in NSDictionary format */
2424
@property (nonatomic, readonly, copy) NSDictionary *wdRect;
2525

2626
/*! Element's name */
27-
@property (nonatomic, readonly, copy) NSString *wdName;
27+
@property (nonatomic, readonly, copy, nullable) NSString *wdName;
2828

2929
/*! Element's label */
30-
@property (nonatomic, readonly, copy) NSString *wdLabel;
30+
@property (nonatomic, readonly, copy, nullable) NSString *wdLabel;
3131

3232
/*! Element's selected state */
3333
@property (nonatomic, readonly, getter = isWDSelected) BOOL wdSelected;
@@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
3939
@property (nonatomic, readonly, strong, nullable) NSString *wdValue;
4040

4141
/*! Element's unique identifier */
42-
@property (nonatomic, readonly, copy) NSString *wdUID;
42+
@property (nonatomic, readonly, copy, nullable) NSString *wdUID;
4343

4444
/*! Whether element is enabled */
4545
@property (nonatomic, readonly, getter = isWDEnabled) BOOL wdEnabled;
@@ -58,6 +58,9 @@ NS_ASSUME_NONNULL_BEGIN
5858
@property (nonatomic, readonly, getter = isWDFocused) BOOL wdFocused;
5959
#endif
6060

61+
/*! Element's index relatively to its parent. Starts from zero */
62+
@property (nonatomic, readonly) NSUInteger wdIndex;
63+
6164
/**
6265
Returns value of given property specified in WebDriver Spec
6366
Check the FBElement protocol to get list of supported attributes.

WebDriverAgentLib/WebDriverAgentLib.framework/Headers/FBElementCache.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,38 @@ extern const int ELEMENT_CACHE_SIZE;
3030
*/
3131
- (nullable NSString *)storeElement:(XCUIElement *)element;
3232

33+
/**
34+
Returns cached element resolved with default snapshot attributes
35+
36+
@param uuid uuid of element to fetch
37+
@return element
38+
@throws FBStaleElementException if the found element is not present in DOM anymore
39+
@throws FBInvalidArgumentException if uuid is nil
40+
*/
41+
- (XCUIElement *)elementForUUID:(NSString *)uuid;
42+
3343
/**
3444
Returns cached element
3545
3646
@param uuid uuid of element to fetch
47+
@param additionalAttributes Add additonal attribute names if the snapshot should contain
48+
them in `addtionalAttributes` section. nil value resolves the snapshot with standard attributes.
49+
@param maxDepth The maximum depth of the snapshot. Only works if additional attributes are provided.
50+
`nil` value means to use the default maximum depth value.
3751
@return element
52+
@throws FBStaleElementException if the found element is not present in DOM anymore
53+
@throws FBInvalidArgumentException if uuid is nil
54+
*/
55+
- (XCUIElement *)elementForUUID:(NSString *)uuid
56+
resolveForAdditionalAttributes:(nullable NSArray <NSString *> *)additionalAttributes
57+
andMaxDepth:(nullable NSNumber *)maxDepth;
58+
59+
/**
60+
Checks element existence in the cache
61+
62+
@returns YES if the element with the given UUID is present in cache
3863
*/
39-
- (nullable XCUIElement *)elementForUUID:(NSString *__nullable)uuid;
64+
- (BOOL)hasElementWithUUID:(nullable NSString *)uuid;
4065

4166
@end
4267

WebDriverAgentLib/WebDriverAgentLib.framework/Headers/FBExceptionHandler.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,6 @@
1212

1313
NS_ASSUME_NONNULL_BEGIN
1414

15-
/*! Exception used to notify about missing session */
16-
extern NSString *const FBSessionDoesNotExistException;
17-
18-
/*! Exception used to notify about application deadlock */
19-
extern NSString *const FBApplicationDeadlockDetectedException;
20-
21-
/*! Exception used to notify about unknown attribute */
22-
extern NSString *const FBElementAttributeUnknownException;
23-
24-
/*! Exception used to notify about invalid argument */
25-
extern NSString *const FBInvalidArgumentException;
26-
27-
/*! Exception used to notify about invisibility of an element while trying to interact with it */
28-
extern NSString *const FBElementNotVisibleException;
29-
30-
/*! Exception used to notify about a timeout */
31-
extern NSString *const FBTimeoutException;
32-
3315
/**
3416
Class used to handle exceptions raised by command handlers
3517
*/

WebDriverAgentLib/WebDriverAgentLib.framework/Headers/FBMathUtils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ BOOL FBFloatFuzzyEqualToFloat(CGFloat float1, CGFloat float2, CGFloat threshold)
2222
/*! Returns whether points are equal within given threshold */
2323
BOOL FBPointFuzzyEqualToPoint(CGPoint point1, CGPoint point2, CGFloat threshold);
2424

25+
/*! Returns whether vectors are equal within given threshold */
26+
BOOL FBVectorFuzzyEqualToVector(CGVector a, CGVector b, CGFloat threshold);
27+
2528
/*! Returns whether size are equal within given threshold */
2629
BOOL FBSizeFuzzyEqualToSize(CGSize size1, CGSize size2, CGFloat threshold);
2730

@@ -38,6 +41,3 @@ CGPoint FBInvertOffsetForOrientation(CGPoint offset, UIInterfaceOrientation orie
3841
/*! Inverts size if necessary to match current screen orientation */
3942
CGSize FBAdjustDimensionsForApplication(CGSize actualSize, UIInterfaceOrientation orientation);
4043
#endif
41-
42-
/*! Replaces the wdRect dictionary passed as the argument with zero-size wdRect if any of its attributes equal to Infinity */
43-
NSDictionary<NSString *, NSNumber *> *FBwdRectNoInf(NSDictionary<NSString *, NSNumber *> *wdRect);

WebDriverAgentLib/WebDriverAgentLib.framework/Headers/FBResponsePayload.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ id<FBResponsePayload> FBResponseWithUnknownErrorFormat(NSString *errorFormat, ..
5454
id<FBResponsePayload> FBResponseWithStatus(FBCommandStatus *status);
5555

5656
/**
57-
Returns a response payload as a NSDictionary for given element and elementUUID.
57+
Returns a response payload as a NSDictionary for given element.
5858
Set compact=NO to include further attributes (defined by FBConfiguration.elementResponseAttributes)
5959
*/
60-
NSDictionary *FBDictionaryResponseWithElement(XCUIElement *element, NSString *elementUUID, BOOL compact);
60+
NSDictionary *FBDictionaryResponseWithElement(XCUIElement *element, BOOL compact);
6161

6262

6363
/**

WebDriverAgentLib/WebDriverAgentLib.framework/Headers/FBRoute.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ typedef __nonnull id<FBResponsePayload> (^FBRouteSyncHandler)(FBRouteRequest *re
4848
*/
4949
+ (instancetype)DELETE:(NSString *)pathPattern;
5050

51+
/**
52+
Convenience constructor for OPTIONS route with given pathPattern
53+
*/
54+
+ (instancetype)OPTIONS:(NSString *)pathPattern;
55+
5156
/**
5257
Chain-able constructor that handles response with given FBRouteSyncHandler block
5358
*/

0 commit comments

Comments
 (0)