com.codeborne.selenide.Condition Java Examples

The following examples show how to use com.codeborne.selenide.Condition. 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: CheckBoxImpl.java    From masquerade with Apache License 2.0 6 votes vote down vote up
@Override
public boolean apply(SpecificCondition condition) {
    return componentApply(match(condition), getDelegate())
            .when(eq(Conditions.CHECKED)).get(() ->
                    $(byChain(by, INPUT)).is(CHECKBOX_CHECKED)
            )
            .when(eq(Conditions.SELECTED)).get(() ->
                    $(byChain(by, INPUT)).is(Condition.selected)
            )
            .when(hasType(Caption.class)).get(c ->
                    impl.has(exactText(c.getCaption()))
            )
            .when(hasType(CaptionContains.class)).get(cc ->
                    impl.has(text(cc.getCaptionSubstring()))
            )
            .when(eq(READONLY)).get(() ->
                    impl.has(readonlyClass)
            )
            .when(eq(EDITABLE)).get(() ->
                    !impl.has(readonlyClass)
            )
            .getMatch();
}
 
Example #2
Source File: AbstractSpecificConditionHandler.java    From masquerade with Apache License 2.0 5 votes vote down vote up
@Override
public T waitUntil(Condition condition, long timeoutMilliseconds) {
    SpecificConditionContext.with(this, () ->
            getDelegate().waitUntil(condition, timeoutMilliseconds)
    );
    return (T) this;
}
 
Example #3
Source File: ElementsVerificationSteps.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Проверка, что кнопка/ссылка недоступна для нажатия, поле или элемент не доступен для редактирования
 */
@Тогда("^(?:ссылка|кнопка|поле|элемент) \"([^\"]*)\" (?:недоступно|недоступен|недоступна)$")
@Then("^(?:link|button|field|element) named \"([^\"]*)\" is not (?:clickable|editable)$")
public void fieldIsDisable(String elementName) {
    SelenideElement element = akitaScenario.getCurrentPage().getElement(elementName);
    assertTrue(element.is(Condition.disabled), String.format("Элемент [%s] доступен", elementName));
}
 
Example #4
Source File: ListInteractionSteps.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Выбор из списка со страницы любого случайного элемента и сохранение его значения в переменную
 */
@Когда("^выбран любой элемент из списка \"([^\"]*)\" и его значение сохранено в переменную \"([^\"]*)\"$")
@When("^random element in \"([^\"]*)\" list has been selected and its value has been saved to the \"([^\"]*)\" variable$")
public void selectRandomElementFromListAndSaveVar(String listName, String varName) {
    List<SelenideElement> listOfElementsFromPage = akitaScenario.getCurrentPage().getElementsList(listName);
    SelenideElement element = listOfElementsFromPage.get(getRandom(listOfElementsFromPage.size()));
    element.shouldBe(Condition.visible).click();
    akitaScenario.setVar(varName, akitaScenario.getCurrentPage().getAnyElementText(element).trim());
    akitaScenario.write(String.format("Переменной [%s] присвоено значение [%s] из списка [%s]", varName,
        akitaScenario.getVar(varName), listName));
}
 
Example #5
Source File: SelenideAddonsTest.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test()
public void testDownVerticalDragAndDropUntilCondition()
{
    Selenide.open("https://demos.telerik.com/kendo-ui/slider/index");

    SelenideElement slider = $("#equalizer .k-slider-vertical:first-child a");
    SelenideAddons.dragAndDropUntilCondition(slider, slider, 0, 10, 3000, 23, Condition.attribute("aria-valuenow", "-6"));

    Assert.assertEquals($("#equalizer .k-slider-vertical:first-child a").getAttribute("aria-valuenow"), "-6");
}
 
Example #6
Source File: SearchIntegrationTest.java    From vaadin-app-layout with Apache License 2.0 5 votes vote down vote up
private void openSearch() {
    Selenide.$("#it-test-search-field").shouldNot(Condition.visible);
    Selenide.$("#it-test-search-button").click();
    sleep(1000);
    Selenide.$("#it-test-search-field").should(Condition.visible);
    Selenide.executeJavaScript("document.getElementById(\"it-test-search-field\").value = \"Header\"");
    sleep(1000);
    $(byText("Header1")).should(Condition.visible);
    $(byText("Description1")).should(Condition.visible);
}
 
Example #7
Source File: N2oImageCell.java    From n2o-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void shapeShouldBe(ImageShape shape) {
    switch (shape) {
        case circle:
            element().$("img").shouldHave(Condition.cssClass("rounded-circle"));
            break;
        case rounded:
            element().$("img").shouldHave(Condition.cssClass("rounded"));
            break;
        case polaroid:
            element().$("img").shouldNotHave(Condition.cssClass("rounded"),Condition.cssClass("rounded-circle"));
            break;
    }
}
 
Example #8
Source File: AbstractSpecificConditionHandler.java    From masquerade with Apache License 2.0 5 votes vote down vote up
@Override
public T shouldNot(Condition... conditions) {
    SpecificConditionContext.with(this, () ->
            getDelegate().shouldNot(conditions)
    );
    return (T) this;
}
 
Example #9
Source File: ElementsVerificationSteps.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Проверка того, что элемент исчезнет со страницы (станет невидимым) в течение DEFAULT_TIMEOUT.
 * В случае, если свойство "waitingCustomElementsTimeout" в application.properties не задано,
 * таймаут равен 15 секундам
 */
@Тогда("^ожидается исчезновение элемента \"([^\"]*)\"")
@Then("^waiting for the element named \"([^\"]*)\" to disappear$")
public void elemDisappered(String elementName) {
    akitaScenario.getCurrentPage().waitElementsUntil(
            Condition.disappears, DEFAULT_TIMEOUT, akitaScenario.getCurrentPage().getElement(elementName));
}
 
Example #10
Source File: N2oInputText.java    From n2o-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void shouldHavePlaceholder(String placeholder) {
    Condition condition = Condition.attribute("placeholder", placeholder);

    SelenideElement elm = inputElement();
    if (elm.exists()) elm.shouldHave(condition);
    else cellInputElement().shouldHave(condition);
}
 
Example #11
Source File: N2oMaskedInputControl.java    From n2o-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void shouldHavePlaceholder(String value) {
    Condition condition = Condition.attribute("placeholder", value);

    SelenideElement elm = element().parent().$(".n2o-input-mask");
    if (elm.exists()) elm.shouldHave(condition);
    else element().$(".n2o-editable-cell .n2o-editable-cell-text").shouldHave(condition);
}
 
Example #12
Source File: AkitaPage.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Проверка того, что элементы, не помеченные аннотацией "Optional", отображаются,
 * а элементы, помеченные аннотацией "Hidden", скрыты.
 */
protected void isAppeared() {
    String timeout = loadProperty("waitingAppearTimeout", WAITING_APPEAR_TIMEOUT_IN_MILLISECONDS);
    getPrimaryElements().parallelStream().forEach(elem ->
            elem.waitUntil(Condition.appear, Integer.valueOf(timeout)));
    getHiddenElements().parallelStream().forEach(elem ->
            elem.waitUntil(Condition.hidden, Integer.valueOf(timeout)));
    eachForm(AkitaPage::isAppeared);
}
 
Example #13
Source File: ElementsVerificationSteps.java    From akita with Apache License 2.0 5 votes vote down vote up
/**
 * Проверка того, что элемент не отображается на странице
 */
@Тогда("^(?:поле|выпадающий список|элемент) \"([^\"]*)\" не отображается на странице$")
@Then("^(?:field|drop-down list|element) named \"([^\"]*)\" is not visible$")
public void elementIsNotVisible(String elementName) {
    akitaScenario.getCurrentPage().waitElementsUntil(
            not(Condition.appear), DEFAULT_TIMEOUT, akitaScenario.getCurrentPage().getElement(elementName)
    );
}
 
Example #14
Source File: N2oPasswordControl.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void passwordShouldBeVisible() {
    SelenideElement elm = inputElement();
    if (elm.exists()) elm.shouldHave(Condition.attribute("type", "text"));
    else element().$(".n2o-editable-cell .n2o-editable-cell-text").shouldHave(Condition.attribute("type", "text"));
}
 
Example #15
Source File: SelenideElementWrapper.java    From masquerade with Apache License 2.0 4 votes vote down vote up
default T waitUntil(Condition condition, long timeoutMilliseconds) {
    getDelegate().waitUntil(condition, timeoutMilliseconds);
    return (T) this;
}
 
Example #16
Source File: N2oRadioGroup.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void check(String label) {
    element().$$("label").findBy(Condition.text(label)).click();
}
 
Example #17
Source File: N2oTextEditor.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void shouldBeEmpty() {
    element().shouldHave(Condition.empty);
}
 
Example #18
Source File: N2oPills.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void check(String label) {
    if (!itemLink(label).is(Condition.cssClass("active")))
        item(label).shouldBe(Condition.exist).click();
}
 
Example #19
Source File: N2oStandardField.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void messageShouldHave(Condition condition) {
    //реализовать, когда понадобится
    throw new UnsupportedOperationException();
}
 
Example #20
Source File: N2oFileUploadControl.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void uploadFileNameShouldBe(int index, String fileName) {
    element().parent().$$(".n2o-file-uploader-files-list .n2o-file-uploader-file-name")
            .get(index).shouldHave(Condition.text(fileName));
}
 
Example #21
Source File: N2oPills.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void shouldBeChecked(String label) {
    itemLink(label).shouldHave(Condition.cssClass("active"));
}
 
Example #22
Source File: N2oFilterHeader.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void clickSearchButton() {
    filterDropdown().$$(".n2o-advanced-table-filter-dropdown-buttons button").find(Condition.text("Искать")).click();
}
 
Example #23
Source File: N2oCheckboxGroup.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void uncheck(String label) {
    if (inputElement(label).isSelected())
        inputElement(label).shouldBe(Condition.exist).parent().$("label").click();
}
 
Example #24
Source File: Conditions.java    From masquerade with Apache License 2.0 4 votes vote down vote up
public static Condition visibleOptionsCount(int count) {
    return new OptionsCount(count);
}
 
Example #25
Source File: N2oSelect.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void clear() {
    element().$(".n2o-input-clear").hover().shouldBe(Condition.visible).click();
}
 
Example #26
Source File: N2oFilterHeader.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void clickResetButton() {
    filterDropdown().$$(".n2o-advanced-table-filter-dropdown-buttons button").find(Condition.text("Сбросить")).click();
}
 
Example #27
Source File: N2oStandardTableHeader.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void shouldBeSortedByDesc() {
    element().$(".n2o-sorting-icon.fa-sort-amount-desc").should(Condition.exist);
}
 
Example #28
Source File: N2oRadioCell.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void shouldBeUnchecked() {
    radioElement().shouldNotBe(Condition.checked);
}
 
Example #29
Source File: Conditions.java    From masquerade with Apache License 2.0 4 votes vote down vote up
public static Condition captionContains(String caption) {
    return new CaptionContains(caption);
}
 
Example #30
Source File: N2oSelect.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void select(Condition by) {
    expandPopUpOptions();
    selectPopUp().$$("button").findBy(by).click();
}