|
20 | 20 | import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
21 | 21 | import static org.openqa.selenium.testing.Safely.safelyCall;
|
22 | 22 | import static org.openqa.selenium.testing.drivers.Browser.EDGE;
|
| 23 | +import static org.openqa.selenium.testing.drivers.Browser.FIREFOX; |
23 | 24 | import static org.openqa.selenium.testing.drivers.Browser.IE;
|
24 | 25 | import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
|
25 | 26 |
|
@@ -143,6 +144,31 @@ void canListenToResponseCompletedEventWithCookie()
|
143 | 144 | }
|
144 | 145 | }
|
145 | 146 |
|
| 147 | + @Test |
| 148 | + @NotYetImplemented(SAFARI) |
| 149 | + @NotYetImplemented(IE) |
| 150 | + @NotYetImplemented(EDGE) |
| 151 | + @NotYetImplemented(FIREFOX) // Implemented in Firefox Nightly version 123 |
| 152 | + void canListenToOnAuthRequiredEvent() |
| 153 | + throws ExecutionException, InterruptedException, TimeoutException { |
| 154 | + try (Network network = new Network(driver)) { |
| 155 | + CompletableFuture<ResponseDetails> future = new CompletableFuture<>(); |
| 156 | + network.onAuthRequired(future::complete); |
| 157 | + page = server.whereIs("basicAuth"); |
| 158 | + driver.get(page); |
| 159 | + |
| 160 | + ResponseDetails response = future.get(5, TimeUnit.SECONDS); |
| 161 | + String windowHandle = driver.getWindowHandle(); |
| 162 | + assertThat(response.getBrowsingContextId()).isEqualTo(windowHandle); |
| 163 | + assertThat(response.getRequest().getRequestId()).isNotNull(); |
| 164 | + assertThat(response.getRequest().getMethod()).isEqualToIgnoringCase("get"); |
| 165 | + assertThat(response.getRequest().getUrl()).isNotNull(); |
| 166 | + assertThat(response.getResponseData().getHeaders().size()).isGreaterThanOrEqualTo(1); |
| 167 | + assertThat(response.getResponseData().getUrl()).contains("basicAuth"); |
| 168 | + assertThat(response.getResponseData().getStatus()).isEqualTo(401L); |
| 169 | + } |
| 170 | + } |
| 171 | + |
146 | 172 | @AfterEach
|
147 | 173 | public void quitDriver() {
|
148 | 174 | if (driver != null) {
|
|
0 commit comments