|
20 | 20 | import static java.nio.charset.StandardCharsets.UTF_8; |
21 | 21 | import static java.util.concurrent.TimeUnit.MINUTES; |
22 | 22 | import static org.assertj.core.api.Assertions.assertThat; |
| 23 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
| 24 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
23 | 25 |
|
24 | 26 | import java.io.StringReader; |
25 | 27 | import java.util.LinkedList; |
|
33 | 35 | import org.junit.jupiter.api.BeforeEach; |
34 | 36 | import org.junit.jupiter.api.Test; |
35 | 37 | import org.openqa.selenium.By; |
| 38 | +import org.openqa.selenium.NoSuchSessionException; |
36 | 39 | import org.openqa.selenium.WebDriver; |
37 | 40 | import org.openqa.selenium.grid.config.MapConfig; |
38 | 41 | import org.openqa.selenium.grid.config.MemoizedConfig; |
@@ -65,7 +68,12 @@ public void setupServers() { |
65 | 68 | DeploymentTypes.DISTRIBUTED.start( |
66 | 69 | browser.getCapabilities(), |
67 | 70 | new TomlConfig( |
68 | | - new StringReader("[node]\n" + "driver-implementation = " + browser.displayName()))); |
| 71 | + new StringReader( |
| 72 | + "[node]\n" |
| 73 | + + "driver-implementation = " |
| 74 | + + browser.displayName() |
| 75 | + + "\n" |
| 76 | + + "session-timeout = 15"))); |
69 | 77 | tearDowns.add(deployment); |
70 | 78 |
|
71 | 79 | server = deployment.getServer(); |
@@ -124,4 +132,15 @@ void multipleSimultaneousSessions() throws Exception { |
124 | 132 |
|
125 | 133 | CompletableFuture.allOf(futures).get(4, MINUTES); |
126 | 134 | } |
| 135 | + |
| 136 | + @Test |
| 137 | + void testStopTimedOutSession() throws Exception { |
| 138 | + assertThat(server.isStarted()).isTrue(); |
| 139 | + WebDriver driver = |
| 140 | + RemoteWebDriver.builder().oneOf(browser.getCapabilities()).address(server.getUrl()).build(); |
| 141 | + driver.get(appServer.getUrl().toString()); |
| 142 | + Thread.sleep(15000); |
| 143 | + NoSuchSessionException exception = assertThrows(NoSuchSessionException.class, driver::getTitle); |
| 144 | + assertTrue(exception.getMessage().startsWith("Cannot find session with id:")); |
| 145 | + } |
127 | 146 | } |
0 commit comments