Sunday, 30 August 2015

6. Waits

Waits



1. Wait for element state

2. Wait for element text

3. Wait for element value

4. Wait for element attribute


Element + waitUntil + Condition or Conditions + Time in ms

For more information about Conditions please refer to 5. Conditions and Assertions 

1. Wait for element state



        $("#username").waitUntil(present, 5000);

        $("#username").waitUntil(enabled, 5000);

        $("#username").waitUntil(disabled, 5000);

        $("#username").waitUntil(visible, 5000);

        $("#username").waitUntil(appears, 5000);

        $("#username").waitUntil(disappears, 5000);

        $("#username").waitUntil(empty, 5000);

        $("#username").waitUntil(focused, 5000);

        $("#username").waitUntil(selected, 5000);   




2. Wait for element text


        $("#welcome").waitUntil(hasText("Hello, Johny!"), 2000);
                
        $("#username").waitUntil(matchesText("Johny"), 2000);
                
        $("#username").waitUntil(not(matchesText("Noname")), 2000);
                
        $("#username").waitUntil(matchText("^Johny$"), 2000);
        



3. Wait for element value


        $("#username").waitUntil(hasValue("123"), 2000);




4. Wait for element attribute


        $("#username").waitUntil(hasAttribute("name", "user.name"), 2000);

        $("#username").waitUntil(hasClass("green-button"), 2000);

1 comment:

  1. How to wait until child dropdown box to show up after choosing option from parent dropdown? My tests is failing randomly. This is what I'm doing in my test
    $("select#reason").shouldBe(visible).selectOption("I only wanted to try the service");
    $("select#reason").drpdwnList_PleaseSelectTheReason.findBy(text("I only wanted to try the service")).shouldBe(selected);
    select#subReason.waitUntil(visible, 5000, 2000).selectOption("I only tried it for the coupon");

    ReplyDelete