-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPerfectoMobileBasicTest
More file actions
89 lines (64 loc) · 1.68 KB
/
PerfectoMobileBasicTest
File metadata and controls
89 lines (64 loc) · 1.68 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
import java.io.File;
import java.io.InputStream;
import com.perfectomobile.httpclient.MediaType;
import com.perfectomobile.httpclient.utils.FileUtils;
import com.perfectomobile.selenium.api.IMobileDriver;
/*
*
* Class Name : PerfectoMobileBasicTest
* Author : Uzi Eilon <uzie@perfectomobile.com>
* Date : Dec 6th 2013
*
* Description :
Basic abstract perfecto mobile test - Each test need to extend this class and implement the actual test in the PerfectoMobileBasicTest
* This basic test handles the driver and the device
*/
public abstract class PerfectoMobileBasicTest implements Runnable{
String _DeviceId = null;
IMobileDriver _driver;
boolean _status = true;
@Override
public void run() {
try
{
execTest();
}catch (Exception e)
{
_status = false;
}
closeTest();
getRep(MediaType.HTML);
}
public PerfectoMobileBasicTest (IMobileDriver driver)
{
_driver = driver;
}
public Boolean getStatus() {
return _status ;
}
public void setDeviceID(String Device) {
_DeviceId= Device;
}
public String getRepName() {
String className = this.getClass().getName();
String name = Constants.REPORT_LIB+className+_DeviceId+".HTML";
return name;
}
public void getRep(MediaType Type) {
InputStream reportStream = ((IMobileDriver) _driver).downloadReport(Type);
if (reportStream != null) {
File reportFile = new File(getRepName());
FileUtils.write(reportStream, reportFile);
}
}
public void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
}
}
public void closeTest( ) {
_driver.quit();
}
public abstract void execTest() throws Exception ;
}