?????????????????????裬??????о?????????????????????????? iOS??????? Web ???????????????? Appium ????????????????????Щ???????????????????? API ?????????????????????????????Щ?????????????????? iOS ???????????????????????????Android ?????????????????
?????????????к????????????????????????д??????μ????????? Google ?????????????????????????????????????????????3???????????????????????Щ???μ???????????? Appium ?????????????Щ????????п??????????????????????????????д????????
????Appium
??????????????????????????????????????????????????????? Appium ????????????????????????????????????????????????
???????????Appium ???????????????????? iOS??Android ?? Web ???????????????????????????д???????????????????????? Appium ????????????д???????????????Щ?????????????????????????(???? iOS )????????????????????????? Appium ?????????????????????? Appium ??????Appium ???????豸?????????????????????????豸?????
?????豸??
??????????? ???????? ??????????? iOS ??????????????????????????? WebDriverAgentRunner ??????????? WDA ?????????????????????? App ???в????
?????e???????????????е????????????????????? app???????????????????????????в?????????????????????
??????????????????????? UI ?????????????? Xcode 7 ???????? UI Automation ???????? JS ????????ò???????? Xcode 7 ??????????μ??? UI Testing ???? Xcode 8 ?и??????????? UI Automation ???????????????????? iOS 9 ???????????汾?У?Appium ????????? UI Testing ???????????????? UI Automation ??
?????????????? UI Testing ?????????????????????????л?????????????????????? Add target ????????????????£????????????????? .m ???????????????:
#import <XCTest/XCTest.h>
@interface Test : XCTestCase
@end
@implementation Test
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
self.continueAfterFailure = NO;
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
[[[XCUIApplication alloc] init] launch];
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
@end
??????????????????????????? setUp ????????????Щ????????????????????? [[[XCUIApplication alloc] init] launch]; ???????????????????????????????? tearDown ????????????????????????
???????е??????????????? test ?????????????? - (void)testExample ???e?????ò????? OC ??????????????????????? Annotation ???????????????????????????????? Java ????????:
????@test
????public void example() {
????// do some test
????}
???????????????????????????????? Command + U ???????в??????????????н???????????? Appium ??????????????? app ????????????ò????е?????????????????????????????е? [[XCUIApplication alloc] init] ???????????????? app ????????????????????? launch ???????????????? app??
???????????????????????????????????????????????????? XCUIApplication ??????????з??????????????????? BundleID:
????[[XCUIApplication alloc] initPrivateWithPath:nil bundleID:@"com.bestswifte.targetapp"];
??????????????????? BundleID ??????????????????????滻??????? ID ????????????? BundleID ??????????????????????á??????????????????????????????????????????з???????????????? XCUIApplication ????????????????????????з?????
?????????????????е??????????滻?????? init ???????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????? testExample ??????????????????? Runloop ??????????????β???????????????????????? TCP ??????????紫????????????
?????????? Facebook ????? WDA ????????????? FBScreenshotCommands.m ???:
#import "FBScreenshotCommands.h"
#import "XCUIDevice+FBHelpers.h"
@implementation FBScreenshotCommands
#pragma mark - <FBCommandHandler>
+ (NSArray *)routes
{
return
@[
[[FBRoute GET:@"/screenshot"].withoutSession respondWithTarget:self action:@selector(handleGetScreenshot:)]??
[[FBRoute GET:@"/screenshot"] respondWithTarget:self action:@selector(handleGetScreenshot:)]??
];
}
#pragma mark - Commands
+ (id<FBResponsePayload>)handleGetScreenshot:(FBRouteRequest *)request
{
NSString *screenshot = [[XCUIDevice sharedDevice].fb_screenshot base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
return FBResponseWithObject(screenshot);
}
@end
??????????????????? /screenshot ??·?????????????????? handleGetScreenshot ?????????????? XCUIDevice ??????????
?????????????????WDA ????·????????????????????????? BundleID ??????????????????????????????????????????????????????????? URL ??????????? URL????????????飬?????????? URL ?????ж???????????????????????????
????Appium ?????
???????????Appium ?????????? Node.js ????????????????????????? WDA ??????????????????????????? URL ?? /screenshot ????????????б??????????????????? WDA ?б???? Appium ??????????????Э?顣????? Appium ????? Android ?????????????????????????????????? Appium ???????н????????????????????????Э????÷???????
????Appium ??????? WebDriver Э?顣?? w3.org ??????????Э?????????????? Selenim ????? ??????? WebDriver Э?顣?????в??????????????????????????? or ????淶????????????????????λ??????:
????WebDriver’s goal is to supply a well-designed object-oriented API that provides improved support for modern advanced web-app testing problems.
???????????? WebDriver ??????????????Э?鼴?ɡ?
????Appium ?????
????Appium ????????????д????Щ??????????Appium ?????????????????????????WebDriver Э???????????????????????????????????????????????????? WebDriver ?淶?? URL?????? https://www.w3.org/TR/webdriver/#list-of-endpoints ?漲???????????????????????????????? URL ?????
????????????????? Java ????????д?????????????????? Android ?????????е?????????д Android??iOS ???????2??????????????
???????
??????? Appium ?????????????仰?????:
??????????????????????????????????? WebDriver Э???μ? URL????? Node ???????????????????????????????????й????в?????? URL?????? WebDriver Э??????????е?????????????????????????????????????????????????? Node ????????
???????????????????:
????iOS ?????????????????????????????????????????????Σ???????????