|
23 | 23 |
|
24 | 24 | import java.time.Duration; |
25 | 25 | import java.time.temporal.ChronoUnit; |
| 26 | +import java.util.Collections; |
26 | 27 | import java.util.concurrent.CountDownLatch; |
27 | 28 | import java.util.concurrent.TimeUnit; |
28 | 29 | import org.junit.jupiter.api.Disabled; |
|
32 | 33 | import org.openqa.selenium.TimeoutException; |
33 | 34 | import org.openqa.selenium.UsernameAndPassword; |
34 | 35 | import org.openqa.selenium.WebDriverException; |
| 36 | +import org.openqa.selenium.WindowType; |
| 37 | +import org.openqa.selenium.bidi.BiDiException; |
| 38 | +import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; |
35 | 39 | import org.openqa.selenium.bidi.module.Network; |
36 | 40 | import org.openqa.selenium.support.ui.ExpectedConditions; |
37 | 41 | import org.openqa.selenium.testing.JupiterTestBase; |
@@ -264,4 +268,56 @@ void canFailRequest() { |
264 | 268 | assertThatThrownBy(() -> driver.get(page)).isInstanceOf(WebDriverException.class); |
265 | 269 | } |
266 | 270 | } |
| 271 | + |
| 272 | + @Test |
| 273 | + @NeedsFreshDriver |
| 274 | + void canSetCacheBehaviorToBypass() { |
| 275 | + try (Network network = new Network(driver)) { |
| 276 | + page = appServer.whereIs("basicAuth"); |
| 277 | + |
| 278 | + BrowsingContext context = new BrowsingContext(driver, WindowType.TAB); |
| 279 | + String contextId = context.getId(); |
| 280 | + |
| 281 | + network.setCacheBehavior(CacheBehavior.BYPASS, Collections.singletonList(contextId)); |
| 282 | + } |
| 283 | + } |
| 284 | + |
| 285 | + @Test |
| 286 | + @NeedsFreshDriver |
| 287 | + void canSetCacheBehaviorToDefault() { |
| 288 | + try (Network network = new Network(driver)) { |
| 289 | + page = appServer.whereIs("basicAuth"); |
| 290 | + |
| 291 | + BrowsingContext context = new BrowsingContext(driver, WindowType.TAB); |
| 292 | + String contextId = context.getId(); |
| 293 | + |
| 294 | + network.setCacheBehavior(CacheBehavior.DEFAULT, Collections.singletonList(contextId)); |
| 295 | + } |
| 296 | + } |
| 297 | + |
| 298 | + @Test |
| 299 | + @NeedsFreshDriver |
| 300 | + void canSetCacheBehaviorWithNoContextId() { |
| 301 | + try (Network network = new Network(driver)) { |
| 302 | + page = appServer.whereIs("basicAuth"); |
| 303 | + |
| 304 | + network.setCacheBehavior(CacheBehavior.BYPASS); |
| 305 | + network.setCacheBehavior(CacheBehavior.DEFAULT); |
| 306 | + } |
| 307 | + } |
| 308 | + |
| 309 | + @Test |
| 310 | + @NeedsFreshDriver |
| 311 | + void throwsExceptionForInvalidContext() { |
| 312 | + try (Network network = new Network(driver)) { |
| 313 | + page = appServer.whereIs("basicAuth"); |
| 314 | + |
| 315 | + assertThatThrownBy( |
| 316 | + () -> |
| 317 | + network.setCacheBehavior( |
| 318 | + CacheBehavior.DEFAULT, Collections.singletonList("invalid-context"))) |
| 319 | + .isInstanceOf(BiDiException.class) |
| 320 | + .hasMessageContaining("no such frame"); |
| 321 | + } |
| 322 | + } |
267 | 323 | } |
0 commit comments