Code Snippets

Wait for an event

$(".username").shouldHave(text("John"));

All "should"- methods automatically wait until web element appears and gets given property (text in this example). Timeout is 4 seconds by default.

Wait for an event with a timeout (longer than default):

 $("#username").waitUntil(hasText("Hello, Johny!"), 8000);

Note that you need "waitUntil" methods in rare specific cases - when you definitely know that this is a long-lasting query, and event is designed to happen after a pause (longer than default 4 seconds).

Get list of matched elements

$$("#paymentScheduleTable tr")

Get element by index

$("#paymentScheduleTable tr", 5)

Clear browser cache

clearBrowserCache();

Hamcrest-style checks

assertThat($("#insuranceDetailsHeader").getText(), equalTo("Страховые полисы"));
assertThat($$("#paymentScheduleTable tr").size(), equalTo(7));