-
Notifications
You must be signed in to change notification settings - Fork 34
/
NetworkSpeedEmulationTest.java
37 lines (33 loc) · 1.87 KB
/
NetworkSpeedEmulationTest.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
package tests.usecases.devtools;
import aquality.selenium.browser.AqualityServices;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.devtools.v131.network.model.ConnectionType;
import org.testng.Assert;
import org.testng.annotations.Test;
import tests.BaseTest;
import theinternet.forms.WelcomeForm;
public class NetworkSpeedEmulationTest extends BaseTest {
private static final int DOWNLOAD_THROUGHPUT = 53;
private static final int DOWNLOAD_THROUGHPUT_BIG = 530000;
private static final int UPLOAD_THROUGHPUT = 27;
private static final int UPLOAD_THROUGHPUT_BIG = 270000;
private static final int LATENCY = 27;
@Test
public void networkSpeedEmulationTest() {
getBrowser().setPageLoadTimeout(AqualityServices.getConfiguration().getTimeoutConfiguration().getScript());
WelcomeForm welcomeForm = new WelcomeForm();
getBrowser().goTo(welcomeForm.getUrl());
Assert.assertTrue(welcomeForm.state().waitForDisplayed(), "Form must be opened");
boolean isOffline = true;
getBrowser().devTools().network().emulateConditions(isOffline, LATENCY, -1, -1);
getBrowser().refresh();
getBrowser().waitForPageToLoad();
Assert.assertFalse(welcomeForm.state().isDisplayed(), "Form must not be opened when offline");
isOffline = false;
getBrowser().devTools().network().emulateConditions(isOffline, LATENCY, DOWNLOAD_THROUGHPUT, UPLOAD_THROUGHPUT, ConnectionType.BLUETOOTH.toString());
Assert.assertThrows(TimeoutException.class, () -> getBrowser().refresh());
getBrowser().devTools().network().emulateConditions(isOffline, LATENCY, DOWNLOAD_THROUGHPUT_BIG, UPLOAD_THROUGHPUT_BIG, ConnectionType.CELLULAR4G.toString());
getBrowser().refresh();
Assert.assertTrue(welcomeForm.state().waitForDisplayed(), "Form must be opened when online with good speed");
}
}