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 test() {
// Example of locating elements using CSS selector and ID
open("https://appr.tc/")
// Wait 10 seconds until "body" element is visible
.setElement(byCssSelector("body")).waitFor(10).untilIsVisible()
// Find "join button" and click on it
.setElement(byId("join-button")).click();
// Wait for 10 seconds
sleep(10 * 1000);
}
public void testGoogleSearch() {
// Example of locating elements using CSS selector
open("https://www.google.com")
// Wait 10 seconds until "body" is visible
.setElement(byCssSelector("body")).waitFor(10).untilIsVisible()
// Find search bar element
.setElement(byCssSelector("input[type=text]"))
// Type "loadero" in it
.sendKeys("loadero")
// Find search button and click it
.setElement(byCssSelector("input[value~='Google']")).click();
}

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‚Äč