Java Code Examples for com.codeborne.selenide.SelenideElement#shouldBe()

The following examples show how to use com.codeborne.selenide.SelenideElement#shouldBe() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: N2oOutputText.java    From n2o-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void shouldBeEmpty() {
    element().shouldBe(Condition.exist);
    SelenideElement elm = element().$(".text");
    if (elm.exists())
        elm.shouldBe(Condition.empty);
}
 
Example 2
Source File: SelenideDockerJupiterTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@Test
public void testDockerSelenideChrome(
        @DockerBrowser(type = CHROME) SelenideDriver driver) {
    driver.open("https://bonigarcia.github.io/selenium-jupiter/");
    SelenideElement about = driver.$(linkText("About"));
    about.shouldBe(visible);
    about.click();
}
 
Example 3
Source File: SelenideDefaultJupiterTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@Test
public void testSelenide(SelenideDriver driver) {
    driver.open("https://bonigarcia.github.io/selenium-jupiter/");
    SelenideElement about = driver.$(linkText("About"));
    about.shouldBe(visible);
    about.click();
}
 
Example 4
Source File: SelenideGlobalConfigJupiterTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@Test
public void testSelenideConfig(SelenideDriver driver) {
    driver.open("https://bonigarcia.github.io/selenium-jupiter/");
    SelenideElement about = driver.$(linkText("About"));
    about.shouldBe(visible);
    about.click();
}
 
Example 5
Source File: N2oDateInput.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void shouldBeEmpty() {
    SelenideElement elm = inputElement();
    if (elm.exists()) elm.shouldBe(Condition.empty);
    else cellInputElement().shouldBe(Condition.empty);
}
 
Example 6
Source File: SelenideAddonsTest.java    From neodymium-library with MIT License 4 votes vote down vote up
@Test()
public void testSafeSupplier()
{
    // preparing the test setup as kind of generator
    AtomicInteger counter = new AtomicInteger(0);
    List<Runnable> runArray = new ArrayList<Runnable>();
    runArray.add(
                 () -> {
                     throw new StaleElementReferenceException("You shall not pass!");
                 });
    runArray.add(
                 () -> {
                     throw new StaleElementReferenceException("You shall not pass!");
                 });
    runArray.add(
                 () -> {
                     throw new StaleElementReferenceException("You shall not pass!");
                 });
    runArray.add(
                 () -> {
                     throw new StaleElementReferenceException("You shall pass!");
                 });
    runArray.add(
                 () -> {
                     throw new StaleElementReferenceException("You shall never be seen!");
                 });
    final Iterator<Runnable> iterator = runArray.iterator();

    // testing the error path after three exceptions
    Selenide.open("https://blog.xceptance.com/");
    long startTime = new Date().getTime();
    try
    {
        SelenideAddons.$safe(() -> {
            counter.incrementAndGet();
            if (iterator.hasNext())
            {
                iterator.next().run();
            }
            return $("body").should(exist);
        });
    }
    catch (StaleElementReferenceException e)
    {
        Assert.assertTrue(e.getMessage().startsWith("You shall pass!"));
    }
    long endTime = new Date().getTime();
    Assert.assertTrue(endTime - startTime > Neodymium.configuration().staleElementRetryTimeout());
    Assert.assertEquals(counter.get(), Neodymium.configuration().staleElementRetryCount() + 1);

    // testing the happy path after one exception
    SelenideElement element = SelenideAddons.$safe(() -> {
        counter.incrementAndGet();
        if (iterator.hasNext())
        {
            iterator.next().run();
        }
        return $("body");
    });
    Assert.assertEquals(counter.get(), Neodymium.configuration().staleElementRetryCount() + 3);
    element.shouldBe(visible);
}