-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoreTestCase.java
More file actions
90 lines (81 loc) · 3.18 KB
/
CoreTestCase.java
File metadata and controls
90 lines (81 loc) · 3.18 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package lib;
import io.appium.java_client.AppiumDriver;
import io.qameta.allure.Step;
import junit.framework.TestCase;
import lib.UI.MainPageObject;
import lib.UI.WelcomePageObject;
import org.junit.After;
import org.junit.Before;
import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.io.FileOutputStream;
import java.util.Properties;
public class CoreTestCase {
protected RemoteWebDriver driver;
private static String AppiumURL = "http://127.0.0.1:4723/";
@Before
@Step("Run driver and session")
public void setUp() throws Exception {
driver = Platform.getInstance().getDriver();
this.createAllurePropertyFile();
this.rotateScreenPortrait();
this.skipWelcomePageForApp();
this.openWikiWebPageForMobileWeb();
}
@After
@Step("Remove driver and session")
public void tearDown() {
driver.quit();
}
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());
}
}
@Step("Rotate screen to LANDSCAPE mode")
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());
}
}
@Step("Skip welcome screen for iOS/Android")
private void skipWelcomePageForApp()
{
if (Platform.getInstance().isiOS()) {
WelcomePageObject WelcomePageObject = new WelcomePageObject(driver);
WelcomePageObject.clickSkip();
} else if (Platform.getInstance().isAndroid()) {
MainPageObject MainPageObject = new MainPageObject(driver);
MainPageObject.clickSkip();
}
}
@Step("Open wikipedia URL for Mobile Web (this method does nothing for Android and iOS)")
protected void openWikiWebPageForMobileWeb()
{
if (Platform.getInstance().isMW()) {
driver.get("https://en.m.wikipedia.org");
} else {
System.out.println("Method openWikiWebPageForMobileWeb() do nothing for platform " + Platform.getInstance().getPlatformVar());
}
}
private void createAllurePropertyFile()
{
String path = System.getProperty("allure.results.directory");
try {
Properties props = new Properties();
FileOutputStream fos = new FileOutputStream(path + "/environment.properties");
props.setProperty("Environment", Platform.getInstance().getPlatformVar());
props.store(fos,"See https://github.com/allure-framework/allure-app/wiki/Environment");
fos.close();
} catch (Exception e) {
System.err.println("IO problem when writing allure properties file");
e.printStackTrace();
}
}
}