Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tasj.b_how_selenide_waits_and_conditions_work;
- import com.codeborne.selenide.Condition;
- import com.codeborne.selenide.Configuration;
- import org.junit.Test;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebElement;
- import static com.codeborne.selenide.Condition.text;
- import static com.codeborne.selenide.Condition.visible;
- import static com.codeborne.selenide.Selenide.$;
- import static com.codeborne.selenide.Selenide.$$;
- import static com.codeborne.selenide.Selenide.open;
- /**
- * Created by yashaka on 6/28/15.
- */
- public class SelenideGoogleSearchTest {
- @Test
- public void testTextSearch(){
- open("http://google.com/ncr");
- // Configuration.timeout = 8000;
- /*
- Selenide Implements a Command Pattern. What is something like:
- ~ robot.do(command)
- */
- // $(By.name("q")).waitUntil(visible, 8000);
- $(By.name("q")).shouldBe(visible); // ~ element.check(whatToCheck);
- /* |
- START>>
- |
- remember START_TIME,
- /--> START_WAIT> |
- / IF (CURRENT_TIME() - START_TIME) > TIMEOUT' THEN THROW_ERROR
- | ELSE |
- ^ | EXIT(FAILED)
- | calls something like: visible.apply($(By.name("q")))
- | |
- | calls $(By.name("q")).isDisplayed()
- | |
- ^ IF_ returned true THEN exit normally
- | (~ "assertion passed")
- | / |
- | / EXIT(PASSED)
- | ELSE'' sleep(100ms),
- \-<------------------------<--------------------------<------------------------<GOTO START_WAIT
- ' TIMEOUT equals to 4s by default
- '' ELSE means: OR returned false OR SOME''' exception is thrown
- ''' SOME means: some predefined exceptions normally thrown by webdriver when element is not found.
- these exceptions are listed in the implementation of shouldBe method.
- */
- $(By.name("q")).setValue("selenium").pressEnter();
- $$(".srg>li.g").get(9).shouldHave(text("A browser automation framework and ecosystem"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment