-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathDeviceFactory.java
More file actions
64 lines (40 loc) · 1.23 KB
/
DeviceFactory.java
File metadata and controls
64 lines (40 loc) · 1.23 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
import java.util.List;
import com.perfectomobile.selenium.*;
import com.perfectomobile.selenium.api.*;
import com.perfectomobile.selenium.options.MobileDeviceFindOptions;
import com.perfectomobile.selenium.options.MobileDeviceOS;
import com.perfectomobile.selenium.options.MobileDeviceProperty;
public class DeviceFactory
{
public static void main(String[] args)
{
IMobileDevice deviceRT = getDevice(DeviceType.Android);
System.out.println( deviceRT.getProperty(MobileDeviceProperty.MODEL) );
}
public enum DeviceType {
Android , iOS , Android_tablet ,iOS_tablet
}
public static IMobileDevice getDevice(DeviceType device ) {
// Android , iOS
MobileDriver PMdriver = new MobileDriver();
MobileDeviceFindOptions op = new MobileDeviceFindOptions();
switch (device) {
case Android:
op.setOS(MobileDeviceOS.ANDROID);
break;
case iOS:
op.setOS(MobileDeviceOS.IOS);
break;
default: System.out.println("no available device");
break;
}
List<IMobileDevice> devlist = PMdriver.findDevices(op);
for (int i = 0 ; i <devlist.size() ; i++)
{
IMobileDevice dev = devlist.get(i);
if (dev.getProperty(MobileDeviceProperty.IN_USE ).equals("false"))
return dev;
}
return null;
}
}