appium_object-c

来源:互联网 发布:上海复旦大学网络教育 编辑:程序博客网 时间:2024/05/24 00:22
#import <Selenium/SERemoteWebDriver.h>


@implementation SeleniumTest


-(void) run
{
SECapabilities *caps = [SECapabilities new];
[caps setPlatform:@"Mac"];
[caps setBrowserName:@"iOS"];
[caps setVersion:@"6.1"];
[caps addCapabilityForKey:@"app" andValue:@"/Users/mac_hy/Library/Developer/Xcode/DerivedData/ZDPrometheus-eanlmixqosrcqbaqvpsbixofcqto/Build/Products/Debug-iphonesimulator/guest.app"];
NSError *error;
SERemoteWebDriver *wd = [[SERemoteWebDriver alloc] initWithServerAddress:@"127.0.0.1" port:4723 desiredCapabilities:caps requiredCapabilities:nil error:&error];
[[wd findElementBy:[SEBY xPath:@"//window[1]/image[3]"]] click];
[[wd findElementBy:[SEBY xPath:@"//window[1]/image[3]"]] click];
[[wd findElementBy:[SEBY name:@"tabbar item unselected 01"]] click];
[[wd findElementBy:[SEBY name:@"手机号码"]] sendKeys:@"131012345678"];
// 131012345678
[[wd findElementBy:[SEBY xPath:@"//window[1]/textfield[1]"]] sendKeys:@"131012345678"];
[[wd findElementBy:[SEBY xPath:@"//window[1]/secure[1]"]] sendKeys:@"123456"];
[[wd findElementBy:[SEBY xPath:@"//window[1]/button[7]"]] click];
[[wd findElementBy:[SEBY xPath:@"//window[1]/scrollview[1]"]] click];
[wd executeScript:@"mobile: swipe" arguments:[[NSArray alloc] initWithObjects:[[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInteger:1, @"touchCount", [NSNumber numberWithFloat:59f, @"startX", [NSNumber numberWithFloat:286f, @"startY", [NSNumber numberWithFloat:70f, @"endX", [NSNumber numberWithFloat:297f, @"endY", [NSNumber numberWithFloat:0.9494141f, @"duration", nil], nil]];
[[wd findElementBy:[SEBY xPath:@"//window[1]/text[1]"]] click];
[[wd findElementBy:[SEBY name:@"apply business dropdown arrow "]] click];
[[wd findElementBy:[SEBY xPath:@"//window[1]/tableview[1]/cell[2]/button[1]"]] click];
[[wd findElementBy:[SEBY xPath:@"//window[1]/textfield[1]"]] sendKeys:@"13101234567"];
[[wd findElementBy:[SEBY name:@"apply business button submit"]] click];
[wd acceptAlert];
[[wd findElementBy:[SEBY xPath:@"//window[4]/alert[1]/text[1]"]] click];
[[wd findElementBy:[SEBY name:@"确定"]] click];
[[wd findElementBy:[SEBY name:@"tabbar item unselected 01"]] click];
[[wd findElementBy:[SEBY name:@"注册"]] click];
[[wd findElementBy:[SEBY xPath:@"//window[1]/textfield[1]"]] sendKeys:@"18321333675"];
[[wd findElementBy:[SEBY name:@"sign up agreement button"]] click];
[wd executeScript:@"  "];
[wd executeScript:@"用户协议"];
[[wd findElementBy:[SEBY name:@"navigation bar button back"]] click];
[[wd findElementBy:[SEBY name:@"sign up agreement button unsel"]] click];
[[wd findElementBy:[SEBY name:@"发送验证码"]] click];
[[wd findElementBy:[SEBY xPath:@"//window[1]/textfield[1]"]] sendKeys:@"804592"];
[[wd findElementBy:[SEBY name:@"(null)"]] sendKeys:@"804592"];
[[wd findElementBy:[SEBY xPath:@"//window[1]/secure[1]"]] sendKeys:@"123456"];
[[wd findElementBy:[SEBY xPath:@"//window[1]/secure[2]"]] sendKeys:@"123456"];
[[wd findElementBy:[SEBY xPath:@"//window[1]/button[2]"]] click];
}