-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoTest.java
156 lines (125 loc) · 4.49 KB
/
AutoTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/**
* Created by jojoyao on 2016/12/2.
*/
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import io.appium.java_client.android.AndroidDriver;
public class AutoTest {
//初始化AppiumDriver
private AndroidDriver driver;
@Before
public void setUp() throws Exception {
// 設定App路徑
//File classpathRoot = new File(System.getProperty("user.air"));
//File app = new File("/Users/jojoyao/Downloads/catchplay-debug-1.1.15-511_original.apk");
System.out.println("設置路徑完成");
//設置自動化相關參數
DesiredCapabilities cap = new DesiredCapabilities();
//cap.setCapability("appium-version", "1.5.3");
//cap.setCapability("platformVersion", "4.4.2");
//cap.setCapability("platformName", "Androiad");
cap.setCapability("deviceName", "Nexus 6P");
System.out.println("設置測試裝置參數完成");
//设置apk路径
//cap.setCapability("app",app.getAbsolutePath());
//如果测试的是AndroidApp的话,需要设置app的package_name & mainActivity-------iOS可以省略
//cap.setCapability("appPackage", "com.catchplay.asiaplay");
//cap.setCapability("appActivity", "com.catchplay.asiaplay.MainActivity");
System.out.println("Apk Load Success");
//初始化 AppiumDriver
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
//設置等待秒數
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
System.out.println("初始化 AppiumDriver");
}
@After
public void tearDown() throws Exception{
//driver.wait(60000);
driver.quit();
//System.out.println("測試结束!!!!!!!");
//System.out.println("即将執行NextSession");
}
@Test
public void allTests() {
System.out.println("Testing Start");
//設true第一個判斷式才會做
boolean pass = true;
if (pass) {
pass = main_testing.openwelcome(driver);
System.out.println("Welcome_Page : " + pass);
}
if (pass) {
pass = main_testing.doLogin_movielover(driver);
System.out.println("Login Movie Lover : " + pass);
}
if(pass)
{
pass = main_testing.DoShareViaFBTesting(driver);
System.out.println("Share via FB : " + pass);
}
if(pass)
{
pass = main_testing.DoGenreTesting(driver);
System.out.println("Genre Testing : " + pass);
}
if(pass)
{
pass = main_testing.DoAddToMyListTestingAsMember(driver);
System.out.println("Add to My List Testing As Member : " + pass);
}
if(pass)
{
pass = main_testing.DoRatingTestingAsMember(driver);
System.out.println("Rating Testing As Member : " + pass);
}
if(pass)
{
pass = main_testing.DoCastAndCrewTesting(driver);
System.out.println("Cast & Crew Testing : " + pass);
}
if(pass)
{
pass = main_testing.DoStillsTetsting(driver);
System.out.println("Stills Testing : " + pass);
}
if(pass)
{
pass = main_testing.DoChangeProfile(driver);
System.out.println("Change Profile : " + pass);
}
if (pass) {
pass = main_testing.doLogout(driver);
System.out.println("LogOut : " + pass);
}
if (pass)
{
pass = main_testing.DoOfflineChecking(driver);
System.out.println("Offline Checking : " + pass);
}
if(pass)
{
pass = main_testing.DoAddToMyListTestingAsGuest(driver);
System.out.println("Add to My List Testing As Guest : " + pass);
}
if(pass)
{
pass = main_testing.DoRatingTestingAsGuest(driver);
System.out.println("Rating Testing As Guest : " + pass);
}
if(pass)
{
pass = main_testing.DoCastAndCrewTesting(driver);
System.out.println("Cast & Crew Testing : " + pass);
}
if(pass)
{
pass = main_testing.DoStillsTetsting(driver);
System.out.println("Stills Testing : " + pass);
}
System.out.println("Testing End");
}
}