Repository navigation
Expand file tree
/
Copy pathCoreTestCase.java
More file actions
72 lines (60 loc) · 2.37 KB
/
Copy pathCoreTestCase.java
File metadata and controls
72 lines (60 loc) · 2.37 KB
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
package lib;
import io.appium.java_client.AppiumDriver;
import junit.framework.TestCase;
import lib.ui.WelcomePageObject;
import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.remote.RemoteWebDriver;
public class CoreTestCase extends TestCase {
protected RemoteWebDriver driver;
@Override
protected void setUp() throws Exception {
super.setUp();
driver = Platform.getInstance().getDriver();
this.rotateScreenPortrait();
this.skipWelcomePageForIOSApp();
this.openWikiWebPageForMobileWeb();
}
@Override
protected void tearDown() throws Exception {
driver.quit();
super.tearDown();
}
protected void rotateScreenPortrait() {
if (driver instanceof AppiumDriver) {
AppiumDriver driver = (AppiumDriver) this.driver;
driver.rotate(ScreenOrientation.PORTRAIT);
} else {
System.out.println("Method rotateScreenPortrait() does nothing for platform " + Platform.getInstance().getPlatformVar());
}
}
protected void rotateScreenLandscape() {
if (driver instanceof AppiumDriver) {
AppiumDriver driver = (AppiumDriver) this.driver;
driver.rotate(ScreenOrientation.LANDSCAPE);
} else {
System.out.println("Method rotateScreenLandscape() does nothing for platform " + Platform.getInstance().getPlatformVar());
}
}
protected void backgroundApp(int seconds) {
if (driver instanceof AppiumDriver) {
AppiumDriver driver = (AppiumDriver) this.driver;
driver.runAppInBackground(seconds);
} else {
System.out.println("Method backgroundApp() does nothing for platform " + Platform.getInstance().getPlatformVar());
}
}
protected void openWikiWebPageForMobileWeb() {
if (Platform.getInstance().isMW()) {
driver.get("https://en.m.wikipedia.org");
} else {
System.out.println("Method openWikiWebPageForMobileWeb() does nothing for platform " + Platform.getInstance().getPlatformVar());
}
}
private void skipWelcomePageForIOSApp() {
if (Platform.getInstance().isIOS()) {
AppiumDriver driver = (AppiumDriver) this.driver;
WelcomePageObject WelcomePageObject = new WelcomePageObject(driver);
WelcomePageObject.clickSkip();
}
}
}