-
Notifications
You must be signed in to change notification settings - Fork 0
/
webmonitor.main.kts
59 lines (50 loc) · 1.89 KB
/
webmonitor.main.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
//usr/bin/env echo '
/**** BOOTSTRAP kscript ****\'>/dev/null
command -v kscript >/dev/null 2>&1 || source /dev/stdin <<< "$(curl -L https://git.io/fpF1K)"
exec kscript $0 "$@"
\*** IMPORTANT: Any code including imports and annotations must come after this line ***/
@file:DependsOn("com.enniovisco:webmonitor:1.3.0")
import com.enniovisco.dsl.*
monitor {
webSource {
screenWidth = 393 // px
screenHeight = 851 // px
// To date Google Chrome is the browser with the most stable APIs
browser = Browser.CHROME_HEADLESS // Alternatively Browser.FIREFOX, Browser.EDGE or Browser.CHROME
wait = 0
maxSessionDuration = 5_000 // ms
targetUrl = "https://enniovisco.github.io/webmonitor/sample.html"
}
spec {
atoms(
select { ".cookieInfo" } // [0]
read "visibility"
equalTo "visible",
select { ".subtitle" }, // [1]
select { "button#close" }, // [2]
select { ".cookieInfo" } read "position" bind "pos",
select { ".cookieInfo" } read "font-size" bind "fs",
select { ".info" } read "position" bind "pos",
select { ".subtitle" } read "font-size" bind "fs"
applying { value, bound ->
parsePixels(value) == parsePixels(bound) * 1.5
},
select { "h2.subtitle" },
select { "p" }
)
record(
after { "click" },
after { "touch" }
)
// helper formulae
val screen = Spec.screen
val popupIsVisible = Spec.atoms[0]
val subtitle = Spec.atoms[1]
val closeButton = Spec.atoms[2]
val er1 = closeButton implies screen
val er2 = not(popupIsVisible and subtitle)
// Final formula
formula = atoms[6] and not(atoms[8]) // and everywhere(er1)
}
}