Skip to main content

Script Examples

Locating elements

By using CSS selector

UIElement element = E(byCssSelector("your.Id"));

By using ID

UIElement element = E(byId("your.Id"));

By using xPath

UIElement element = E(byXpath("//some"));

It is possible to use all strategies by switching back and forth.

public void testUIWithLoadero() {
// Example of locating elements using CSS selector
open("https://www.bing.com")

// Wait 10 seconds until page is visible
.setElement(byCssSelector(".dimmer")).waitFor(10).untilIsVisible()

// Save a screenshot of https://bing.com website
.saveScreenshot("website_bing.png")

// Find search bar element
.setElement(byCssSelector("[type=search]"))

// Type "QA Processes" in it
.sendKeys("QA Processes")

// Find search button and click it
.setElement(byCssSelector("#search_icon")).click()

// Wait for search results to become visible
.setElement(byCssSelector("[aria-label='Search Results']")).waitFor(10).untilIsVisible()

// Take a screenshot of the search results
.saveScreenshot("search_results.png");
}
public void testUIWithLoadero() {
// Example of locating elements using CSS selector
open("https://www.google.com")
// Wait 10 seconds until page is visible
.setElement(byCssSelector("[action=\"/search\"]")).waitFor(10).untilIsVisible()
// Save a screenshot of https://google.com website
.saveScreenshot("website_google.png")
// Find search bar element
.setElement(byCssSelector("textarea[type='search']"))
// Type "QA Processes" in it
.sendKeys("QA Processes")
// Find search button and click it
.setElement(byCssSelector("input[value~='Google']")).click()
// Wait for search results to become visible
.setElement(byCssSelector("div#rso")).waitFor(10).untilIsVisible()
// Take a screenshot of the search results
.saveScreenshot("search_results.png");
}

Using TestUI Element Assertion methods

element.(shouldBe()/shouldHave())
(.not())
.visible()
.enabled()
.Exists()
.exactText("someText")/containText("")/containNoCaseSensitiveText("")
.value("someValue")
.attribute("attributeName").equalTo("value")
.theAttribute("attribute")
element.waitFor(timeInteger)
.untilIs(Not)Visible()
.untilIs(Not)Enabled()
.until(Not)Exist()
.untilHas(Not)Text("someText")
.untilHas(Not)Value("someValue")
.untilHas(Not)Attribute("someAttribute")

You can find detailed descriptions and more examples in TestUI wiki