Search in sources :

Example 51 with When

use of io.cucumber.java.en.When in project syndesis-qe by syndesisio.

the class CommonSteps method createConnectionUsingOAuth.

@When("^.*create connection \"([^\"]*)\" with name \"([^\"]*)\" using oauth$")
public void createConnectionUsingOAuth(String connectorName, String newConnectionName) {
    Connections connectionsPage = new Connections();
    NameConnectionSteps nameConnectionSteps = new NameConnectionSteps();
    navigateTo("Connections");
    validatePage("Connections");
    ElementsCollection connections = connectionsPage.getAllConnections();
    connections = connections.filter(exactText(newConnectionName));
    assertThat(connections.size()).as("Connection with name " + newConnectionName + " already exists!").isEqualTo(0);
    clickOnLink("Create Connection");
    // sometimes page is loaded but connections are not so we need to wait here a bit
    TestUtils.sleepIgnoreInterrupt(TestConfiguration.getJenkinsDelay());
    selectConnectionTypeSteps.selectConnectionType(connectorName);
    // slenide did validation before it reached correct page, but lets wait a second (it helps, trust me!)
    TestUtils.sleepForJenkinsDelayIfHigher(1);
    doOAuthValidation(connectorName);
    assertThat(WebDriverRunner.currentFrameUrl()).containsIgnoringCase("review").containsIgnoringCase("connections/create");
    nameConnectionSteps.setConnectionName(newConnectionName);
    try {
        TestUtils.sleepForJenkinsDelayIfHigher(2);
        OpenShiftWaitUtils.waitFor(() -> !syndesisRootPage.getCurrentUrl().contains("connections/create"), 2, 20);
    } catch (TimeoutException | InterruptedException e) {
        clickOnButton("Save");
        TestUtils.waitFor(() -> !syndesisRootPage.getCurrentUrl().contains("connections/create"), 2, 20, "Unable to create a connection - create button does nothing.");
    }
}
Also used : Connections(io.syndesis.qe.pages.connections.Connections) ElementsCollection(com.codeborne.selenide.ElementsCollection) NameConnectionSteps(io.syndesis.qe.steps.connections.wizard.phases.NameConnectionSteps) TimeoutException(java.util.concurrent.TimeoutException) When(io.cucumber.java.en.When)

Example 52 with When

use of io.cucumber.java.en.When in project syndesis-qe by syndesisio.

the class CommonSteps method clickOnLink.

@When(".*clicks? on the \"(\\d+)\". \"([^\"]*)\" link.*$")
public void clickOnLink(int position, String linkTitle) {
    // e.g. first position is 0 index
    int index = position - 1;
    new SyndesisRootPage().getLink(linkTitle, index).shouldBe(visible).click();
}
Also used : SyndesisRootPage(io.syndesis.qe.pages.SyndesisRootPage) When(io.cucumber.java.en.When)

Example 53 with When

use of io.cucumber.java.en.When in project syndesis-qe by syndesisio.

the class CommonSteps method saveAfterTime.

/**
 * Save current time to the singleton class
 */
@When("^save time after request for integration ([^\"]*)$")
public void saveAfterTime(String integrationName) {
    // due to border values
    TestUtils.sleepIgnoreInterrupt(3000);
    calendarUtils.setAfterRequest(Calendar.getInstance(), integrationName);
    log.info("Time after request was saved: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendarUtils.getLastAfterRequest().getTime()));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) When(io.cucumber.java.en.When)

Example 54 with When

use of io.cucumber.java.en.When in project syndesis-qe by syndesisio.

the class CommonSteps method selectsFromDropdown.

@When("^select \"([^\"]*)\" from \"([^\"]*)\" dropdown$")
public void selectsFromDropdown(String option, String selectDataTestid) {
    // search by name or by data-testid because some dropdowns have only id
    SelenideElement selectElement = $(ByUtils.dataTestId("select", selectDataTestid)).shouldBe(visible);
    selectElement.selectOption(option);
}
Also used : SelenideElement(com.codeborne.selenide.SelenideElement) When(io.cucumber.java.en.When)

Example 55 with When

use of io.cucumber.java.en.When in project syndesis-qe by syndesisio.

the class ApiProviderFlowSteps method mapErrors.

/**
 * Assumes that the page is already on the proper step configuration
 * Expects following datatable (following the petstore example):
 * | <error type>         | <value>           |
 * | Server error         | 400               |
 * | SQL Entity Not Found | 404 Pet not found |
 * It's fine to use both just error codes or error codes with description
 */
@When("map Api Provider errors")
public void mapErrors(DataTable table) {
    Map<String, String> data = table.asMap(String.class, String.class);
    data.forEach((error, response) -> {
        String normalizedId = error.replace(' ', '-').toLowerCase();
        // In case of Server error the id used in UI is server-error not server-error-error
        if (normalizedId.endsWith("-error")) {
            normalizedId = normalizedId.replace("-error", "");
        }
        SelenideElement dropdown = $(ByUtils.dataTestId(String.format(ERROR_FORMAT, normalizedId)));
        Matcher matcher = ERROR_CODE_PATTERN.matcher(response);
        if (matcher.matches()) {
            // Matching by error description
            dropdown.selectOption(response);
        } else {
            // Matching just by error code
            dropdown.selectOptionByValue(response);
        }
    });
}
Also used : Matcher(java.util.regex.Matcher) SelenideElement(com.codeborne.selenide.SelenideElement) When(io.cucumber.java.en.When)

Aggregations

When (io.cucumber.java.en.When)111 SelenideElement (com.codeborne.selenide.SelenideElement)23 Map (java.util.Map)10 File (java.io.File)8 AttributeType (com.vaticle.typedb.core.concept.type.AttributeType)7 ModalDialogPage (io.syndesis.qe.pages.ModalDialogPage)7 Attribute (com.vaticle.typedb.core.concept.thing.Attribute)6 Account (io.syndesis.qe.account.Account)6 Form (io.syndesis.qe.fragments.common.form.Form)6 Syndesis (io.syndesis.qe.resource.impl.Syndesis)6 TimeoutException (java.util.concurrent.TimeoutException)6 RoleType (com.vaticle.typedb.core.concept.type.RoleType)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Slf4j (lombok.extern.slf4j.Slf4j)5 ElementsCollection (com.codeborne.selenide.ElementsCollection)4 DataTable (io.cucumber.datatable.DataTable)4 IntegrationsEndpoint (io.syndesis.qe.endpoint.IntegrationsEndpoint)4 SyndesisRootPage (io.syndesis.qe.pages.SyndesisRootPage)4 List (java.util.List)4