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

The following examples show how to use com.codeborne.selenide.SelenideElement#shouldHave() . 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: 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 2
Source File: TableImpl.java    From masquerade with Apache License 2.0 5 votes vote down vote up
@Override
public Table sort(String columnId, SortDirection direction) {
    if (columnId.startsWith("column_")) {
        columnId = columnId.substring("column_".length());
    }

    SelenideElement columnHeaderCell = $(byChain(by, byClassName("v-table-header"), byCubaId("column_" + columnId)))
            .shouldBe(visible)
            .shouldHave(cssClass("v-table-header-sortable"));

    SortDirection currentDirection = getSortDirection(columnHeaderCell);

    // lets calculate exact click count, because sort can be slow
    for (int i = 0; i < getSortClickCount(currentDirection, direction); i++) {
        columnHeaderCell.click();
    }

    // final check
    String directionSuffix = toSortSuffix(direction);
    if (!directionSuffix.isEmpty()) {
        columnHeaderCell.shouldHave(cssClass("v-table-header-cell-" + directionSuffix));
    } else {
        columnHeaderCell
                .shouldNotHave(cssClass("v-table-header-cell-asc"))
                .shouldNotHave(cssClass("v-table-header-cell-desc"));
    }

    return this;
}
 
Example 3
Source File: DataGridImpl.java    From masquerade with Apache License 2.0 5 votes vote down vote up
@Override
public DataGrid sort(String columnId, SortDirection direction) {
    if (columnId.startsWith("column_")) {
        columnId = columnId.substring("column_".length());
    }

    SelenideElement columnHeaderCell = $(byChain(by, byClassName("v-grid-header"), byCubaId("column_" + columnId)))
            .shouldBe(visible)
            .shouldHave(cssClass("sortable"));

    DataGrid.SortDirection currentDirection = getSortDirection(columnHeaderCell);

    // lets calculate exact click count, because sort can be slow
    for (int i = 0; i < getSortClickCount(currentDirection, direction); i++) {
        columnHeaderCell.click();
    }

    // final check
    String directionSuffix = toSortSuffix(direction);
    if (!directionSuffix.isEmpty()) {
        columnHeaderCell.shouldHave(cssClass("sort-" + directionSuffix));
    } else {
        columnHeaderCell
                .shouldNotHave(cssClass("sort-asc"))
                .shouldNotHave(cssClass("sort-desc"));
    }

    return this;
}
 
Example 4
Source File: N2oPasswordControl.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 = inputElement();
    if (elm.exists()) elm.shouldHave(condition);
    else element().$(".n2o-editable-cell .n2o-editable-cell-text").shouldHave(condition);
}
 
Example 5
Source File: N2oPasswordControl.java    From n2o-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void shouldHaveValue(String value) {
    SelenideElement elm = inputElement();
    if (elm.exists()) elm.shouldHave(value == null || value.isEmpty() ?
            Condition.empty : Condition.value(value));
    else element().$(".n2o-editable-cell .n2o-editable-cell-text").shouldHave(value == null || value.isEmpty() ?
            Condition.empty : Condition.text(value));
}
 
Example 6
Source File: N2oDateInput.java    From n2o-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void shouldHaveValue(String value) {
    SelenideElement elm = inputElement();
    if (elm.exists()) elm.shouldHave(value == null || value.isEmpty() ? Condition.empty : Condition.value(value));
    else cellInputElement().shouldHave(value == null || value.isEmpty() ?
            Condition.empty : Condition.text(value));
}
 
Example 7
Source File: N2oInputText.java    From n2o-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void shouldHaveValue(String value) {
    SelenideElement elm = inputElement();
    if (elm.exists()) elm.shouldHave(value == null || value.isEmpty() ?
            Condition.empty : Condition.value(value));
    else cellInputElement().shouldHave(value == null || value.isEmpty() ?
            Condition.empty : Condition.text(value));
}
 
Example 8
Source File: N2oInputMoney.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 = inputElement();
    if (elm.exists()) elm.shouldHave(condition);
    else element().$(".n2o-editable-cell .n2o-editable-cell-text").shouldHave(condition);
}
 
Example 9
Source File: N2oInputMoney.java    From n2o-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void shouldHaveValue(String value) {
    SelenideElement elm = inputElement();
    if (elm.exists()) elm.shouldHave(value == null || value.isEmpty() ?
            Condition.empty : Condition.value(value));
    else element().$(".n2o-editable-cell .n2o-editable-cell-text").shouldHave(value == null || value.isEmpty() ?
            Condition.empty : Condition.text(value));
}
 
Example 10
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 11
Source File: N2oMaskedInputControl.java    From n2o-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void shouldHaveValue(String value) {
    SelenideElement elm = element().parent().$(".n2o-input-mask");
    if (elm.exists()) elm.shouldHave(value == null || value.isEmpty() ?
            Condition.empty : Condition.value(value));
    else element().$(".n2o-editable-cell .n2o-editable-cell-text").shouldHave(value == null || value.isEmpty() ?
            Condition.empty : Condition.text(value));
}
 
Example 12
Source File: N2oDateInput.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 = inputElement();
    if (elm.exists()) elm.shouldHave(condition);
    else cellInputElement().shouldHave(condition);
}
 
Example 13
Source File: N2oPasswordControl.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.shouldHave(Condition.empty);
    else element().$(".n2o-editable-cell .n2o-editable-cell-text").shouldHave(Condition.empty);
}
 
Example 14
Source File: N2oInputMoney.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.shouldHave(Condition.empty);
    else element().$(".n2o-editable-cell .n2o-editable-cell-text").shouldHave(Condition.empty);
}
 
Example 15
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 16
Source File: N2oPasswordControl.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void passwordShouldNotBeVisible() {
    SelenideElement elm = inputElement();
    if (elm.exists()) elm.shouldHave(Condition.attribute("type", "password"));
    else element().$(".n2o-editable-cell .n2o-editable-cell-text").shouldHave(Condition.attribute("type", "password"));
}
 
Example 17
Source File: N2oSlider.java    From n2o-framework with Apache License 2.0 4 votes vote down vote up
private void shouldHaveValue(SelenideElement element, String value) {
    element.shouldHave(Condition.attribute("aria-valuenow", value));
}