|
16 | 16 | import org.openqa.selenium.By; |
17 | 17 | import org.openqa.selenium.WebElement; |
18 | 18 | import org.openqa.selenium.chromium.ChromiumDriverLogLevel; |
| 19 | +import org.openqa.selenium.chromium.ChromiumNetworkConditions; |
19 | 20 | import org.openqa.selenium.edge.EdgeDriver; |
20 | 21 | import org.openqa.selenium.edge.EdgeDriverService; |
21 | 22 | import org.openqa.selenium.edge.EdgeOptions; |
|
24 | 25 | import org.openqa.selenium.logging.LoggingPreferences; |
25 | 26 | import org.openqa.selenium.remote.service.DriverFinder; |
26 | 27 |
|
27 | | - |
28 | 28 | public class EdgeTest extends BaseTest { |
29 | 29 | @AfterEach |
30 | 30 | public void clearProperties() { |
@@ -190,4 +190,29 @@ public void setPermissions() { |
190 | 190 | Assertions.assertEquals("denied", permissionState); |
191 | 191 | driver.quit(); |
192 | 192 | } |
| 193 | + |
| 194 | + @Test |
| 195 | + public void setNetworkConditions() { |
| 196 | + driver = new EdgeDriver(); |
| 197 | + |
| 198 | + ChromiumNetworkConditions networkConditions = new ChromiumNetworkConditions(); |
| 199 | + networkConditions.setOffline(false); |
| 200 | + networkConditions.setLatency(java.time.Duration.ofMillis(20)); // 20 ms of latency |
| 201 | + networkConditions.setDownloadThroughput(2000 * 1024 / 8); // 2000 kbps |
| 202 | + networkConditions.setUploadThroughput(2000 * 1024 / 8); // 2000 kbps |
| 203 | + |
| 204 | + ((EdgeDriver) driver).setNetworkConditions(networkConditions); |
| 205 | + |
| 206 | + driver.get("https://www.selenium.dev"); |
| 207 | + |
| 208 | + // Assert the network conditions are set as expected |
| 209 | + ChromiumNetworkConditions actualConditions = ((EdgeDriver) driver).getNetworkConditions(); |
| 210 | + Assertions.assertAll( |
| 211 | + () -> Assertions.assertEquals(networkConditions.getOffline(), actualConditions.getOffline()), |
| 212 | + () -> Assertions.assertEquals(networkConditions.getLatency(), actualConditions.getLatency()), |
| 213 | + () -> Assertions.assertEquals(networkConditions.getDownloadThroughput(), actualConditions.getDownloadThroughput()), |
| 214 | + () -> Assertions.assertEquals(networkConditions.getUploadThroughput(), actualConditions.getUploadThroughput()) |
| 215 | + ); |
| 216 | + driver.quit(); |
| 217 | + } |
193 | 218 | } |
0 commit comments