Skip to content

Commit

Permalink
Merge pull request #227 from AirtestProject/feature/appium
Browse files Browse the repository at this point in the history
更新支持15.4
  • Loading branch information
yimelia authored Apr 28, 2022
2 parents b53e265 + 59d6cb1 commit 87a0321
Show file tree
Hide file tree
Showing 39 changed files with 463 additions and 927 deletions.
2 changes: 2 additions & 0 deletions WebDriverAgent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.WebDriverAgentRunner;
PRODUCT_NAME = "$(TARGET_NAME)";
USES_XCTRUNNER = YES;
VALIDATE_WORKSPACE = YES;
};
name = Debug;
};
Expand All @@ -364,6 +365,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.WebDriverAgentRunner;
PRODUCT_NAME = "$(TARGET_NAME)";
USES_XCTRUNNER = YES;
VALIDATE_WORKSPACE = YES;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ typedef struct {
unsigned short _field2;
unsigned short _field3[1];
} CDStruct_27a325c0;

int _XCTSetApplicationStateTimeout(double timeout);
double _XCTApplicationStateTimeout(void);
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,22 @@ NS_ASSUME_NONNULL_BEGIN
+ (instancetype)fb_activeApplicationWithDefaultBundleId:(nullable NSString *)bundleId;

/**
Constructor used to get the system application
Constructor used to get the system application (e.g. Springboard on iOS)
*/
+ (instancetype)fb_systemApplication;

/**
It allows to turn on/off waiting for application quiescence, while performing queries. Defaults to NO.
Retrieves the list of all currently active applications
*/
@property (nonatomic, assign) BOOL fb_shouldWaitForQuiescence;
+ (NSArray<FBApplication *> *)fb_activeApplications;

/**
Switch to system app (called Springboard on iOS)
@param error If there is an error, upon return contains an NSError object that describes the problem.
@return YES if the operation succeeds, otherwise NO.
*/
+ (BOOL)fb_switchToSystemApplicationWithError:(NSError **)error;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

#import <Foundation/Foundation.h>

//#import "AXSettings.h"
//#import "UIKeyboardImpl.h"
//#import "TIPreferencesController.h"
// #import "AXSettings.h"
// #import "UIKeyboardImpl.h"
// #import "TIPreferencesController.h"

NS_ASSUME_NONNULL_BEGIN

extern NSString *const FBSnapshotMaxDepthKey;

/**
Accessors for Global Constants.
*/
Expand All @@ -28,16 +30,29 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)setShouldUseCompactResponses:(BOOL)value;
+ (BOOL)shouldUseCompactResponses;

/*! If set to YES (which is the default), the app will be terminated at the end of the session, if a bundleId was specified */
+ (void)setShouldTerminateApp:(BOOL)value;
+ (BOOL)shouldTerminateApp;

/*! If shouldUseCompactResponses == NO, is the comma-separated list of fields to return with each element. Defaults to "type,label". */
+ (void)setElementResponseAttributes:(NSString *)value;
+ (NSString *)elementResponseAttributes;

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

/*! Enables the extended XCTest debug logging. Useful for developemnt purposes */
+ (void)enableXcTestDebugLogs;

/*! Disables attribute key path analysis, which will cause XCTest on Xcode 9.x to ignore some elements */
+ (void)disableAttributeKeyPathAnalysis;

/*! Disables XCTest automated screenshots taking */
+ (void)disableScreenshots;

/*! Enables XCTest automated screenshots taking */
+ (void)enableScreenshots;

/* The maximum typing frequency for all typing activities */
+ (void)setMaxTypingFrequency:(NSUInteger)value;
+ (NSUInteger)maxTypingFrequency;
Expand All @@ -46,10 +61,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)setShouldUseSingletonTestManager:(BOOL)value;
+ (BOOL)shouldUseSingletonTestManager;

/* Whether to wait for quiescence on application startup */
+ (void)setShouldWaitForQuiescence:(BOOL)value;
+ (BOOL)shouldWaitForQuiescence;

/**
* Extract switch value from arguments
*
Expand Down Expand Up @@ -107,36 +118,54 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (BOOL)verboseLoggingEnabled;

+ (BOOL)shouldLoadSnapshotWithAttributes;
/**
Disables automatic handling of XCTest UI interruptions.
*/
+ (void)disableApplicationUIInterruptionsHandling;

/**
* Configure keyboards preference to make test running stable
*/
+ (void)configureDefaultKeyboardPreferences;


/**
* Turn on softwar keyboard forcefully for simulator.
*/
+ (void)forceSimulatorSoftwareKeyboardPresence;

/**
Defines keyboard preference enabled status
*/
typedef NS_ENUM(NSInteger, FBConfigurationKeyboardPreference) {
FBConfigurationKeyboardPreferenceDisabled = 0,
FBConfigurationKeyboardPreferenceEnabled = 1,
FBConfigurationKeyboardPreferenceNotSupported = 2,
};

/**
* Modify keyboard configuration of 'auto-correction'.
*
* @param isEnabled Turn the configuration on if the value is YES
*/
+ (void)setKeyboardAutocorrection:(BOOL)isEnabled;
+ (BOOL)keyboardAutocorrection;
+ (FBConfigurationKeyboardPreference)keyboardAutocorrection;

/**
* Modify keyboard configuration of 'predictive'
*
* @param isEnabled Turn the configuration on if the value is YES
*/
+ (void)setKeyboardPrediction:(BOOL)isEnabled;
+ (BOOL)keyboardPrediction;
+ (FBConfigurationKeyboardPreference)keyboardPrediction;

/**
* The maximum time to wait until accessibility snapshot is taken
*
* @param timeout The number of float seconds to wait (15 seconds by default)
*/
+ (void)setSnapshotTimeout:(NSTimeInterval)timeout;
+ (NSTimeInterval)snapshotTimeout;
+ (void)setCustomSnapshotTimeout:(NSTimeInterval)timeout;
+ (NSTimeInterval)customSnapshotTimeout;

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

/**
* Whether to bound the lookup results by index.
* By default this is disabled and bounding by accessibility is used.
* Read https://stackoverflow.com/questions/49307513/meaning-of-allelementsboundbyaccessibilityelement
* for more details on these two bounding methods.
*
* @param enabled Either YES or NO
*/
+ (void)setBoundElementsByIndex:(BOOL)enabled;
+ (BOOL)boundElementsByIndex;

/**
* Modify reduce motion configuration in accessibility.
* It works only for Simulator since Real device has security model which allows chnaging preferences
Expand All @@ -181,6 +221,28 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)setReduceMotionEnabled:(BOOL)isEnabled;
+ (BOOL)reduceMotionEnabled;

/**
* Set the idling timeout. If the timeout expires then WDA
* tries to interact with the application even if it is not idling.
* Setting it to zero disables idling checks.
* The default timeout is set to 10 seconds.
*
* @param timeout The actual timeout value in float seconds
*/
+ (void)setWaitForIdleTimeout:(NSTimeInterval)timeout;
+ (NSTimeInterval)waitForIdleTimeout;

/**
* Set the idling timeout for different actions, for example events synthesis, rotation change,
* etc. If the timeout expires then WDA tries to interact with the application even if it is not idling.
* Setting it to zero disables idling checks.
* The default timeout is set to 2 seconds.
*
* @param timeout The actual timeout value in float seconds
*/
+ (void)setAnimationCoolOffTimeout:(NSTimeInterval)timeout;
+ (NSTimeInterval)animationCoolOffTimeout;

/**
Enforces the page hierarchy to include non modal elements,
like Contacts. By default such elements are not present there.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ NS_ASSUME_NONNULL_BEGIN
*/
@protocol FBElement <NSObject>

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

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

/*! Element's name */
@property (nonatomic, readonly, copy) NSString *wdName;
@property (nonatomic, readonly, copy, nullable) NSString *wdName;

/*! Element's label */
@property (nonatomic, readonly, copy) NSString *wdLabel;
@property (nonatomic, readonly, copy, nullable) NSString *wdLabel;

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

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

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

/*! Element's index relatively to its parent. Starts from zero */
@property (nonatomic, readonly) NSUInteger wdIndex;

/**
Returns value of given property specified in WebDriver Spec
Check the FBElement protocol to get list of supported attributes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,38 @@ extern const int ELEMENT_CACHE_SIZE;
*/
- (nullable NSString *)storeElement:(XCUIElement *)element;

/**
Returns cached element resolved with default snapshot attributes
@param uuid uuid of element to fetch
@return element
@throws FBStaleElementException if the found element is not present in DOM anymore
@throws FBInvalidArgumentException if uuid is nil
*/
- (XCUIElement *)elementForUUID:(NSString *)uuid;

/**
Returns cached element
@param uuid uuid of element to fetch
@param additionalAttributes Add additonal attribute names if the snapshot should contain
them in `addtionalAttributes` section. nil value resolves the snapshot with standard attributes.
@param maxDepth The maximum depth of the snapshot. Only works if additional attributes are provided.
`nil` value means to use the default maximum depth value.
@return element
@throws FBStaleElementException if the found element is not present in DOM anymore
@throws FBInvalidArgumentException if uuid is nil
*/
- (XCUIElement *)elementForUUID:(NSString *)uuid
resolveForAdditionalAttributes:(nullable NSArray <NSString *> *)additionalAttributes
andMaxDepth:(nullable NSNumber *)maxDepth;

/**
Checks element existence in the cache
@returns YES if the element with the given UUID is present in cache
*/
- (nullable XCUIElement *)elementForUUID:(NSString *__nullable)uuid;
- (BOOL)hasElementWithUUID:(nullable NSString *)uuid;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,6 @@

NS_ASSUME_NONNULL_BEGIN

/*! Exception used to notify about missing session */
extern NSString *const FBSessionDoesNotExistException;

/*! Exception used to notify about application deadlock */
extern NSString *const FBApplicationDeadlockDetectedException;

/*! Exception used to notify about unknown attribute */
extern NSString *const FBElementAttributeUnknownException;

/*! Exception used to notify about invalid argument */
extern NSString *const FBInvalidArgumentException;

/*! Exception used to notify about invisibility of an element while trying to interact with it */
extern NSString *const FBElementNotVisibleException;

/*! Exception used to notify about a timeout */
extern NSString *const FBTimeoutException;

/**
Class used to handle exceptions raised by command handlers
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ BOOL FBFloatFuzzyEqualToFloat(CGFloat float1, CGFloat float2, CGFloat threshold)
/*! Returns whether points are equal within given threshold */
BOOL FBPointFuzzyEqualToPoint(CGPoint point1, CGPoint point2, CGFloat threshold);

/*! Returns whether vectors are equal within given threshold */
BOOL FBVectorFuzzyEqualToVector(CGVector a, CGVector b, CGFloat threshold);

/*! Returns whether size are equal within given threshold */
BOOL FBSizeFuzzyEqualToSize(CGSize size1, CGSize size2, CGFloat threshold);

Expand All @@ -38,6 +41,3 @@ CGPoint FBInvertOffsetForOrientation(CGPoint offset, UIInterfaceOrientation orie
/*! Inverts size if necessary to match current screen orientation */
CGSize FBAdjustDimensionsForApplication(CGSize actualSize, UIInterfaceOrientation orientation);
#endif

/*! Replaces the wdRect dictionary passed as the argument with zero-size wdRect if any of its attributes equal to Infinity */
NSDictionary<NSString *, NSNumber *> *FBwdRectNoInf(NSDictionary<NSString *, NSNumber *> *wdRect);
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ id<FBResponsePayload> FBResponseWithUnknownErrorFormat(NSString *errorFormat, ..
id<FBResponsePayload> FBResponseWithStatus(FBCommandStatus *status);

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


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ typedef __nonnull id<FBResponsePayload> (^FBRouteSyncHandler)(FBRouteRequest *re
*/
+ (instancetype)DELETE:(NSString *)pathPattern;

/**
Convenience constructor for OPTIONS route with given pathPattern
*/
+ (instancetype)OPTIONS:(NSString *)pathPattern;

/**
Chain-able constructor that handles response with given FBRouteSyncHandler block
*/
Expand Down
Loading

0 comments on commit 87a0321

Please sign in to comment.