-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathParallelExecutions
More file actions
153 lines (109 loc) · 4.31 KB
/
ParallelExecutions
File metadata and controls
153 lines (109 loc) · 4.31 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
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
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.interactions.*;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.WebDriver.*;
import com.perfectomobile.selenium.*;
import com.perfectomobile.selenium.api.*;
import com.perfectomobile.selenium.by.*;
import com.perfectomobile.selenium.output.*;
import com.perfectomobile.selenium.options.*;
import com.perfectomobile.selenium.options.visual.*;
import com.perfectomobile.selenium.options.visual.image.*;
import com.perfectomobile.selenium.options.visual.text.*;
import com.perfectomobile.selenium.options.touch.*;
import com.perfectomobile.httpclient.MediaType;
import com.perfectomobile.httpclient.utils.FileUtils;
public class ParallelMobileTest_Executor implements Runnable {
IMobileDevice device;
MobileDriver driver;
public ParallelMobileTest_Executor() {
driver = new MobileDriver();
}
public IMobileDevice getDevice() {
return device;
}
public void setDevice(String deviceId) {
this.device = driver.getDevice(deviceId);
}
public static void main(String[] args) {
System.out.println("Run started");
ParallelMobileTest_Executor test1 = new ParallelMobileTest_Executor();
ParallelMobileTest_Executor test2 = new ParallelMobileTest_Executor();
test1.setDevice("123456789");
test2.setDevice("1234567890");
ExecutorService executor = Executors.newFixedThreadPool(2);
executor.execute(test1);
executor.execute(test2);
executor.shutdown();
}
private static void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
}
}
@Override
public void run() {
try {
System.out.println("Script started on device " + device.getProperty(MobileDeviceProperty.DEVICE_ID));
device.open();
sleep(1000);
device.home();
System.out.println("Sleep started" );
sleep(5000);
String repositoryKey = "PUBLIC:PMIOSDemoInstrumented.ipa";
sleep(6000);
device.installApplication(repositoryKey);
IMobileWebDriver webDriver = device.getVisualDriver();
webDriver.manageMobile().visualOptions().validationOptions()
.setScroll(true);
webDriver.manageMobile().visualOptions().validationOptions()
.setMaxScroll(5);
webDriver.manageMobile().visualOptions().validationOptions()
.setNext("SWIPE_LEFT");
webDriver.findElement(By.linkText("PMIOSDemo")).click();
device.getProperty(MobileDeviceProperty.MANUFACTURER);
webDriver.manageMobile().visualOptions().init();
webDriver.manageMobile().visualOptions().selectOptions().setShift(MobileShiftOptions.LEFT);
webDriver.manageMobile().visualOptions().selectOptions().setOffset("30%");
webDriver.findElement(By.linkText("User")).sendKeys("John");
sleep(4000);
webDriver.manageMobile().visualOptions().init();
webDriver.manageMobile().visualOptions().selectOptions().setShift(MobileShiftOptions.LEFT);
webDriver.manageMobile().visualOptions().selectOptions().setOffset("30%");
webDriver.findElement(By.linkText("Password")).sendKeys("Perfecto1");
sleep(5000);
webDriver.manageMobile().visualOptions().init();
webDriver.manageMobile().visualOptions().textMatchOptions().setIndex(2);
webDriver.findElement(By.linkText("Login")).click();
webDriver.manageMobile().visualOptions().init();
webDriver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
webDriver.findElement(By.linkText("Continue")).click();
webDriver.manageMobile().visualOptions().init();
webDriver.findElement(By.linkText("Third Screen")).click();
webDriver.manageMobile().visualOptions().init();
webDriver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
webDriver.manageMobile().visualOptions().validationOptions().setScroll(true);
webDriver.manageMobile().visualOptions().validationOptions().setNext("SWIPE_UP");
WebElement webElement = webDriver11.findElement(By.linkText("Skype"));
device.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
driver.quit();
}
System.out.println("Script ended");
}
}