-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeployDeviceWithRequirements.java
More file actions
154 lines (141 loc) · 7.02 KB
/
DeployDeviceWithRequirements.java
File metadata and controls
154 lines (141 loc) · 7.02 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
153
package examples;
import com.google.common.collect.ImmutableMap;
import com.testfabrik.webmate.javasdk.*;
import com.testfabrik.webmate.javasdk.devices.*;
import examples.helpers.Helpers;
import examples.helpers.WebElementFunction;
import io.appium.java_client.MobileBy;
import io.appium.java_client.android.AndroidDriver;
import org.apache.commons.io.IOUtils;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.runners.MethodSorters;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Objects;
import static examples.MyCredentials.WEBMATE_API_URI;
import static examples.MyCredentials.WEBMATE_PROJECTID;
@RunWith(JUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class DeployDeviceWithRequirements {
private static WebmateAPISession webmateSession;
private static DeviceDTO device;
@Before
public void setup() throws URISyntaxException {
WebmateAuthInfo authInfo = new WebmateAuthInfo(MyCredentials.WEBMATE_APIKEY);
webmateSession = new WebmateAPISession(
authInfo,
WebmateEnvironment.create(new URI(WEBMATE_API_URI)),
WEBMATE_PROJECTID
);
}
/**
* This will deploy a device with the specified Operating System version.
* For iOS, the full version including minor level is required. For Windows and macOS, specifying _64 is required.
* Note that with macOS you also need to provide the name instead of the numeric version.
**/
@Test
public void deployDeviceWithPlatformRequirement() throws IOException {
device = webmateSession.device.requestDeviceByRequirements(WEBMATE_PROJECTID,
new DeviceRequest("Sample Device",
new DeviceRequirements(
ImmutableMap.of(
DevicePropertyName.Platform, "Android_13",
// DevicePropertyName.Platform, "iOS_16.1.1",
// DevicePropertyName.Platform, "WINDOWS_11_64",
// DevicePropertyName.Platform, "MACOS_MONTEREY_64",
DevicePropertyName.AutomationAvailable, true))));
}
/**
* This will deploy a specific device model. Only available for iOS and Android.
* To deploy a version specific macOS or Windows device, use the platform requirement above.
**/
@Test
public void deployDeviceWithModelRequirement() throws IOException {
device = webmateSession.device.requestDeviceByRequirements(WEBMATE_PROJECTID,
new DeviceRequest("Sample Device",
new DeviceRequirements(
ImmutableMap.of(
DevicePropertyName.Model, "iPhone 11",
// DevicePropertyName.Model, "Galaxy Tab A8",
DevicePropertyName.AutomationAvailable, true))));
}
/**
* This will deploy a device with a specific browser version.
**/
@Test
public void deployDeviceWithBrowserRequirement() throws IOException {
device = webmateSession.device.requestDeviceByRequirements(WEBMATE_PROJECTID,
new DeviceRequest("Sample Device",
new DeviceRequirements(
ImmutableMap.of(
DevicePropertyName.Browsers, ImmutableMap.of(
"browserType", "safari",
"version", "16"
),
// DevicePropertyName.Browsers, ImmutableMap.of(
// "browserType", "chrome",
// "version", "116"
// ),
DevicePropertyName.AutomationAvailable, true))));
}
/**
* This will deploy a device with a specific language.
* At this time, only Windows and macOS are supported.
**/
@Test
public void deployDeviceWithLanguageRequirement() throws IOException {
device = webmateSession.device.requestDeviceByRequirements(WEBMATE_PROJECTID,
new DeviceRequest("Sample Device",
new DeviceRequirements(
ImmutableMap.of(
DevicePropertyName.Language, "en",
// DevicePropertyName.Language, "de",
DevicePropertyName.AutomationAvailable, true))));
}
/**
* Of course, it is possible to mix and match all the above requirements to get a device that fits your needs.
* The following example will deploy a German Windows 11 device with Chrome 116.
**/
@Test
public void deploySpecificDesktop() throws IOException {
device = webmateSession.device.requestDeviceByRequirements(WEBMATE_PROJECTID,
new DeviceRequest("Sample Device",
new DeviceRequirements(
ImmutableMap.of(
DevicePropertyName.Language, "de",
DevicePropertyName.Browsers, ImmutableMap.of(
"browserType", "chrome",
"version", "116"
),
DevicePropertyName.Platform, "WINDOWS_11_64",
DevicePropertyName.AutomationAvailable, true))));
}
/**
* You can also mix and match for mobile devices as well.
* The following example will specifically deploy a Galaxy Tab A8 device with Chrome 120 and Android 12.
**/
@Test
public void deploySpecificMobile() throws IOException {
device = webmateSession.device.requestDeviceByRequirements(WEBMATE_PROJECTID,
new DeviceRequest("Sample Device",
new DeviceRequirements(
ImmutableMap.of(
DevicePropertyName.Model, "Galaxy Tab A8",
DevicePropertyName.Browsers, ImmutableMap.of(
"browserType", "chrome",
"version", "120"
),
DevicePropertyName.Platform, "Android_12",
DevicePropertyName.AutomationAvailable, true))));
}
}