?????????????????????瑁�??????芯?????????????????????????? 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 ?????????????????????????????????????????????危???????????