com.codeborne.selenide.Conditional Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selenide-core Show documentation
Show all versions of selenide-core Show documentation
Selenide = concise API for Selenium WebDriver
package com.codeborne.selenide;
import com.codeborne.selenide.impl.Waiter;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.time.Duration;
/**
*
* Implements wait for non WebElement based conditions.
* Accepts predicate as condition.
*
*
*
* To use it just implement for appropriate type,
* e.g. {@code YourType implements Conditional}
*
*
* {@link com.codeborne.selenide.impl.Waiter}
* @since 5.23.0
*/
@ParametersAreNonnullByDefault
public interface Conditional {
/**
* @return current Driver (used to take screenshots etc. in case of test failure)
*/
@Nonnull
@CheckReturnValue
Driver driver();
/**
* @return object under test
*/
@Nonnull
@CheckReturnValue
T object();
@Nonnull
default Conditional shouldHave(ObjectCondition predicate) {
new Waiter().wait(driver(), object(), predicate);
return this;
}
@Nonnull
default Conditional shouldHave(ObjectCondition predicate, Duration timeout) {
new Waiter().wait(driver(), object(), predicate, timeout);
return this;
}
@Nonnull
default Conditional shouldNotHave(ObjectCondition predicate) {
new Waiter().waitWhile(driver(), object(), predicate);
return this;
}
@Nonnull
default Conditional shouldNotHave(ObjectCondition predicate, Duration timeout) {
new Waiter().waitWhile(driver(), object(), predicate, timeout);
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy