forked from saucelabs-training/demo-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmusimWebAppTests.java
100 lines (87 loc) · 3.77 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
package com.saucedemo.tests;
import com.pages.LoginPage;
import com.pages.ProductsPage;
import com.saucedemo.Endpoints;
import com.saucedemo.WebTestsBase;
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;
import java.net.MalformedURLException;
import java.util.Arrays;
import java.util.Collection;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@RunWith(Parameterized.class)
public class EmusimWebAppTests extends WebTestsBase {
/*
* 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", "14.3", "iPhone XS Max Simulator"},
{"Safari", "iOS", "14.3", "iPhone XS Simulator"},
{"Safari", "iOS", "14.3", "iPhone SE (2nd generation) Simulator"},
// Duplication below for demo purposes of massive parallelization
{"Safari", "iOS", "14.3", "iPhone XS Max Simulator"},
{"Safari", "iOS", "14.3", "iPhone XS Simulator"},
{"Safari", "iOS", "14.3", "iPhone SE (2nd generation) Simulator"},
{"Safari", "iOS", "14.3", "iPhone XS Max Simulator"},
{"Safari", "iOS", "14.3", "iPhone XS Simulator"},
{"Safari", "iOS", "14.3", "iPhone SE (2nd generation) Simulator"},
{"Safari", "iOS", "14.3", "iPhone XS Max Simulator"},
{"Safari", "iOS", "14.3", "iPhone XS Simulator"},
{"Safari", "iOS", "14.3", "iPhone SE (2nd generation) Simulator"},
});
}
@Before
public void setUp() throws MalformedURLException {
//Configure these using Platform Configurator:
// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
MutableCapabilities capabilities = new MutableCapabilities();
capabilities.setCapability("browserName", browserName);
capabilities.setCapability("platformName", platform);
capabilities.setCapability("platformVersion", platformVersion);
capabilities.setCapability("deviceName", deviceName);
capabilities.setCapability("name", testName.getMethodName());
capabilities.setCapability("build", buildName);
capabilities.setCapability("idleTimeout", "90");
capabilities.setCapability("newCommandTimeout", "90");
//Emusim devices have Simulator/Emulator in the name
driver = new RemoteWebDriver(Endpoints.getEmusimHub(), capabilities);
resultReportingTestWatcher.setDriver(driver);
}
@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());
}
}