Skip to content

Commit

Permalink
Update IOSAppTest.java
Browse files Browse the repository at this point in the history
  • Loading branch information
baozhida authored Feb 28, 2017
1 parent 494c645 commit c54c5eb
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/testngcase/ios/IOSAppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,22 @@ public void beforecase() throws Exception {
}

@Test
public void case_1进入旅游() {
public void case_001xxx() {
// set screenshot save path
//String courseFile = directory.getCanonicalPath();
System.out.println("------------1-点击旅游图片,进入旅游频道------------------");
try {
driver.sleep(5000);
Element el = driver.elementByXPath("//XCUIElementTypeApplication[1]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[1]"
+ "/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]"
+ "/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]"
+ "/XCUIElementTypeCollectionView[1]/XCUIElementTypeCell[3]/XCUIElementTypeOther[1]"
+ "/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeImage[1]");
Element el = driver.elementByXPath("//*[@name='xxx']");
System.out.println("------------旅游控件存在------------------");

el.click();
//判断到达新页面
assertTrueReWrite("assertTrue:元素未找到!",driver.sleep(5000).isElementExist("xpath", "//XCUIElementTypeStaticText[@name='旅游']/following-sibling::XCUIElementTypeOther"));
assertTrueReWrite("assertTrue:元素未找到!",driver.sleep(5000).isElementExist("xpath", "//*[@name='xxx']"));
//screenShot();
System.out.println("------------控件存在------------------");

//返回首页
driver.elementByXPath("//XCUIElementTypeButton[@name='tab channel topbar back']").click();
driver.elementByXPath("//*[@name='tab back']").click();
driver.sleep(2000);
isFail = false;
} catch (Exception e) {
Expand All @@ -110,7 +105,7 @@ public void aftercase() throws Exception {
if(isFail==true){
//如果用例执行出错,检查是否在首页,如果不再首页,点击页面右上角的点,返回
for(int i=1;i<=5;i++){
if(driver.isElementExist("xpath", "//XCUIElementTypeButton[@name='首页']") == true){
if(driver.isElementExist("xpath", "//*[@name='首页']") == true){
return;
}else{
driver.tap(21, 42);
Expand All @@ -119,7 +114,6 @@ public void aftercase() throws Exception {
}
//如果5次循环都不能到首页,重新初始化driver
initDriver();
//return;
}
}

Expand Down

0 comments on commit c54c5eb

Please sign in to comment.