Search in sources :

Example 31 with ElementsCollection

use of com.codeborne.selenide.ElementsCollection in project syndesis-qe by syndesisio.

the class IntegrationSteps method deleteRandomStepsAndCheckRest.

// what rest??
@Then("^she deletes \"(\\d+)\" random integration steps and checks the rest$")
public void deleteRandomStepsAndCheckRest(Integer numberOfSteps) {
    log.info("Deleting random phases");
    List<String> list = editPage.getFlowViewComponent().getStepsArray();
    ElementsCollection deletes = editPage.getFlowViewComponent().getAllTrashes().shouldBe(sizeGreaterThanOrEqual(1));
    int count = deletes.size();
    List<Integer> randomIndexes = new ArrayList<>();
    for (int i = 0; i < numberOfSteps; i++) {
        randomIndexes.add((int) Math.floor(Math.random() * (count - 2 - i)));
    }
    for (Integer randomIndex : randomIndexes) {
        deletes.get(randomIndex + 1).click();
        editPage.getFirstVisibleButton("OK").shouldBe(visible).click();
        list.remove(randomIndex);
    }
    List<String> list2 = editPage.getFlowViewComponent().getStepsArray();
    for (int i = 0; i < list.size(); i++) {
        log.info("assserting {} and {", list.get(i), list2.get(i));
        assertThat(list.get(i), is(list2.get(i)));
    }
}
Also used : ElementsCollection(com.codeborne.selenide.ElementsCollection) ArrayList(java.util.ArrayList) Then(cucumber.api.java.en.Then)

Aggregations

ElementsCollection (com.codeborne.selenide.ElementsCollection)31 SelenideElement (com.codeborne.selenide.SelenideElement)15 ArrayList (java.util.ArrayList)9 Then (cucumber.api.java.en.Then)4 When (cucumber.api.java.en.When)2 StepComponent (io.syndesis.qe.pages.integrations.edit.steps.StepComponent)2 Given (cucumber.api.java.en.Given)1 ModalDialogPage (io.syndesis.qe.pages.ModalDialogPage)1 Connections (io.syndesis.qe.pages.connections.Connections)1 BasicFilterStepComponent (io.syndesis.qe.pages.integrations.edit.steps.BasicFilterStepComponent)1 ConfigureConnectionSteps (io.syndesis.qe.steps.connections.wizard.phases.ConfigureConnectionSteps)1 NameConnectionSteps (io.syndesis.qe.steps.connections.wizard.phases.NameConnectionSteps)1 List (java.util.List)1