@@ -25,6 +25,12 @@ import kotlin.time.Duration.Companion.seconds
25
25
@Testcontainers
26
26
class IntegrationTests {
27
27
28
+ /* *
29
+ * A container running the "raw" Chrome with support for the JSON HTTP API of the DevTools protocol (in addition to
30
+ * the web socket API).
31
+ *
32
+ * One must first connect via the HTTP API at `http://localhost:{port}` and then get the web socket URL from there.
33
+ */
28
34
@Container
29
35
var chromeContainer: GenericContainer <* > = GenericContainer (" zenika/alpine-chrome" )
30
36
.withExposedPorts(9222 )
@@ -51,17 +57,18 @@ class IntegrationTests {
51
57
val version = chrome.version()
52
58
assertTrue(version.browser.contains(" Chrome" ))
53
59
assertTrue(version.userAgent.contains(" HeadlessChrome" ))
54
- assertTrue(version.webSocketDebuggerUrl.startsWith(" ws://localhost " ) )
60
+ assertTrue(version.webSocketDebuggerUrl.startsWith(" ws://" ), " the debugger URL should start with ws://, but was: ${version.webSocketDebuggerUrl} " )
55
61
56
62
val protocolJson = chrome.protocolJson()
57
63
assertTrue(protocolJson.isNotEmpty(), " the JSON definition of the protocol should not be empty" )
58
64
59
- val targets = chrome.targets()
60
- assertTrue(targets.isNotEmpty(), " there should be at least the about:blank target" )
61
-
62
65
@Suppress(" DEPRECATION" ) // the point is to test this deprecated API
63
- val googleTab = chrome.newTab(" https://www.google.com" )
66
+ val googleTab = chrome.newTab(url = " https://www.google.com" )
64
67
assertEquals(" https://www.google.com" , googleTab.url.trimEnd(' /' ))
68
+
69
+ val targets = chrome.targets()
70
+ assertTrue(targets.any { it.url.trimEnd(' /' ) == " https://www.google.com" }, " the google.com page target should be listed, got: $targets " )
71
+
65
72
chrome.closeTab(googleTab.id)
66
73
}
67
74
}
0 commit comments