Skip to content

Commit

Permalink
feat: enhanced DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
ennioVisco committed Jun 17, 2024
1 parent beae23f commit b0cfe31
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 39 deletions.
39 changes: 0 additions & 39 deletions test.main.kts

This file was deleted.

53 changes: 53 additions & 0 deletions webmonitor.main.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env kotlin

@file:DependsOn("com.enniovisco:webmonitor:1.2.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)
}
}

0 comments on commit b0cfe31

Please sign in to comment.