I want to have some nicer, more "human-like" ways to select elements, similar to playwright's locators.
Here is an idea of expressing something like that with a builder pattern:
import chrobot/locator
/// Specify a button locator, then issue a command to it
pub fn wibble() -> Result(Wibble, Wobble) {
locator.new()
|> locator.role_button()
|> locator.text("Submit")
|> locator.click()
}
import chrobot/locator
import gleeunit/should
/// Use a locator to select an element and assert against an attribute
pub fn wibble() {
locator.new()
|> locator.role_button()
|> locator.text("Submit")
|> locator.timeout(1000)
|> locator.get_attribute("data-lustre-on-click")
|> should.be_ok
|> should.equal("0-0-1")
}
import chrobot/locator
/// Use a locator to select an input and fill in text (focus+type)
pub fn wibble() {
locator.new()
|> locator.label("First Name")
|> locator.fill("Lucy")
}
Locators would have built-in polling with a default timeout that can be specified as part of the builder with locator.timeout and will be set to a reasonable default otherwise.
In the example above, locator.click(), locator.get_attribute() and locator.fill() take in a locator and run a query against the browser with it, all functions before it are part of the locator builder.
I want to have some nicer, more "human-like" ways to select elements, similar to playwright's locators.
Here is an idea of expressing something like that with a builder pattern:
Locators would have built-in polling with a default timeout that can be specified as part of the builder with
locator.timeoutand will be set to a reasonable default otherwise.In the example above,
locator.click(),locator.get_attribute()andlocator.fill()take in a locator and run a query against the browser with it, all functions before it are part of the locator builder.