-
Notifications
You must be signed in to change notification settings - Fork 123
/
EmuSimWebAppTests.java
104 lines (89 loc) · 3.88 KB
/
EmuSimWebAppTests.java
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
package com.saucedemo.tests;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import com.saucedemo.Endpoints;
import com.saucedemo.MobileTestsBase;
import com.saucedemo.pages.LoginPage;
import com.saucedemo.pages.ProductsPage;
import java.net.MalformedURLException;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.remote.RemoteWebDriver;
/** Emulator / Simulator Web Tests. */
@RunWith(Parameterized.class)
public class EmuSimWebAppTests extends MobileTestsBase {
/*
* Configure our data driven parameters
* */
@Parameterized.Parameter public String browserName;
@Parameterized.Parameter(1)
public String platform;
@Parameterized.Parameter(2)
public String platformVersion;
@Parameterized.Parameter(3)
public String deviceName;
@Parameterized.Parameters()
public static Collection<Object[]> crossBrowserData() {
return Arrays.asList(
new Object[][] {
{"Safari", "iOS", "16.2", "iPhone XS Max Simulator"},
{"Safari", "iOS", "16.2", "iPhone XS Simulator"},
{"Safari", "iOS", "16.2", "iPhone SE (2nd generation) Simulator"}
// Duplication below for demo purposes of massive parallelization
// https://saucelabs.com/products/platform-configurator#/
// {"Safari", "iOS", "16.2", "iPhone XS Max Simulator"},
// {"Safari", "iOS", "16.2", "iPhone XS Simulator"},
// {"Safari", "iOS", "16.2", "iPhone SE (2nd generation) Simulator"},
// {"Safari", "iOS", "16.2", "iPhone XS Max Simulator"},
// {"Safari", "iOS", "16.2", "iPhone XS Simulator"},
// {"Safari", "iOS", "16.2", "iPhone SE (2nd generation) Simulator"},
// {"Safari", "iOS", "16.2", "iPhone XS Max Simulator"},
// {"Safari", "iOS", "16.2", "iPhone XS Simulator"},
// {"Safari", "iOS", "16.2", "iPhone SE (2nd generation) Simulator"},
});
}
@Before
public void setUp() throws MalformedURLException {
// Configure these using Platform Configurator:
// https://saucelabs.com/products/platform-configurator#/
MutableCapabilities capabilities = new MutableCapabilities();
capabilities.setCapability("browserName", browserName);
capabilities.setCapability("platformName", platform);
capabilities.setCapability("appium:platformVersion", platformVersion);
capabilities.setCapability("appium:deviceName", deviceName);
capabilities.setCapability("appium:automationName", "XCUITest");
MutableCapabilities sauceOptions = new MutableCapabilities();
sauceOptions.setCapability("name", testName.getMethodName());
sauceOptions.setCapability("build", buildName);
capabilities.setCapability("sauce:options", sauceOptions);
// EmuSim devices have Simulator/Emulator in the name
driver = new RemoteWebDriver(Endpoints.getEmuSimHub(), capabilities);
}
@Test
public void loginWorks() {
LoginPage loginPage = new LoginPage(driver);
loginPage.visit();
loginPage.login("standard_user");
assertTrue(new ProductsPage(driver).isDisplayed());
}
@Test(expected = TimeoutException.class)
public void lockedOutUser() {
LoginPage loginPage = new LoginPage(driver);
loginPage.visit();
loginPage.login("locked_out_user");
assertFalse(new ProductsPage(driver).isDisplayed());
}
@Test(expected = TimeoutException.class)
public void invalidCredentials() {
LoginPage loginPage = new LoginPage(driver);
loginPage.visit();
loginPage.login("foo_bar_user");
assertFalse(new ProductsPage(driver).isDisplayed());
}
}