本文共 4592 字,大约阅读时间需要 15 分钟。
Before: desiredCapabilities.setCapability(CapabilityType.PLATFORM, "iOS"); desiredCapabilities.setCapability(CapabilityType.VERSION, "7.0"); Current: desiredCapabilities.setCapability("platformVersion", "7.0");desiredCapabilities.setCapability("platformName", "iOS"); |
public class PassportLogin extends BaseTest { private static Logger log = Logger.getLogger(PassportLogin.class); @DataProvider(name = "passportLoginData") public static Object[][] passportLoginData() { return new Object[][] { { "正确的网易通行证登录", "xxxxx@163.com", "xxxxx", "" }, { "非网易账号的网易通行证登录", "xxx@qq.com", "xxxx", "" }, { "网易通行证登录,密码错误", "xxxx@163.com", "xxx", "用户名或密码错误" }, { "不输入账号和密码", "", "", "用户名不能为空" }, { "不输入密码", "xxx@163.com", "", "密码不能为空" }, { "不输入账号", "", "xxxx", "用户名不能为空" }, { "错误的网易通行证登录", MyRandom.getRandomString(10) + "@163.com", MyRandom.getRandomString(6), "用户名或密码错误" } }; } @BeforeClass public void setUp() { driver = new Orange(); mainPage = new MainPage(driver); account = new Account(driver); as = new AssertSettings(driver); usPage = new UserSettingsPage(driver); homePage = new HomePage(driver); mainPage.enterMainPage(); mainPage.enterLogin(); account.logoutTrue(); } @AfterClass public void tearDown() { driver.quit(); } @AfterMethod public void end() throws InterruptedException { log.info("-------------------------------------------------------------------"); } @Test(dataProvider = "passportLoginData") public void passportLoginTest(String testName, String passport, String password, String errorCode) throws InterruptedException { log.info("测试内容:" + testName); mainPage.enterLogin(); account.login(passport, password); if (errorCode != "") { boolean b = as.assertLogin(errorCode); driver.sleep(3000); mainPage.flickToRight(); mainPage.closePage(); Assert.assertTrue(b); } else { mainPage.enterLogin(); homePage.settingsClick(); usPage.passportClick(); account.logout(); } } } |
public class Account extends BasePage { /** * @Title: Account * @Description: TODO * @param @param driver * @throws */ public Account(Orange driver) { super(driver); // TODO Auto-generated constructor stub } /** * @Title: login * @Description: TODO * @param @param driver * @return void * @throws */ public void login() { driver.clickOnElement(By.name("网易通行证登录")); driver.sendKeys(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATextField[1]"), PropertiesHandle.readValue("passport_2")); driver.sendKeys(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIASecureTextField[1]"), PropertiesHandle.readValue("password")); driver.clickOnElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[1]")); } /** * @Title: login * @Description: TODO * @param @param driver * @param @param passport * @param @param password * @return void * @throws */ public void login(String passport, String password) { driver.clickOnElement(By.name("网易通行证登录")); driver.sendKeys(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATextField[1]"), passport); driver.sendKeys(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIASecureTextField[1]"), password); driver.clickOnElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[1]")); } /** * @Title: login * @Description: TODO * @param @param type * @param @param passport * @param @param password * @return void * @throws */ public void login(String type, String passport, String password) { driver.clickOnElement(By.name(type)); driver.sendKeys(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATextField[1]"), passport); driver.sendKeys(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIASecureTextField[1]"), password); driver.clickOnElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[1]")); } /** * @Title: login * @Description: TODO * @param @param type * @return void * @throws */ public void login(String type) { driver.clickOnElement(By.name(type)); } /** * @Title: logout * @Description: TODO * @param @param driver * @return void * @throws */ public void logout() { driver.clickOnElement(By.name("退出当前帐号")); driver.clickOnElement(By.name("确定")); } } |
转载地址:http://eriga.baihongyu.com/