Search in sources :

Example 16 with When

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

the class CommonSteps method fillTextIntoTextEditor.

// for CodeMirror text editor
@When("^fill text into text-editor$")
public void fillTextIntoTextEditor(DataTable data) {
    StringBuilder text = new StringBuilder();
    data.asList().forEach(s -> {
        text.append(s);
    });
    new Form(new SyndesisRootPage().getRootElement()).fillEditor(text.toString());
}
Also used : SyndesisRootPage(io.syndesis.qe.pages.SyndesisRootPage) Form(io.syndesis.qe.fragments.common.form.Form) When(io.cucumber.java.en.When)

Example 17 with When

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

the class CommonSteps method navigateToHelp.

@When("^.*navigates? to the \"([^\"]*)\" page in help menu$")
public void navigateToHelp(String title) {
    SelenideElement helpDropdownMenu = $(Element.HELP_DROPDOWN_BUTTON).shouldBe(visible);
    // open the help menu
    if (helpDropdownMenu.parent().$$(Element.DROPDOWN_MENU).size() < 1) {
        helpDropdownMenu.click();
    }
    SelenideElement dropdownElementsTable = $(Element.DROPDOWN_MENU).shouldBe(visible);
    ElementsCollection dropdownElements = dropdownElementsTable.findAll(By.tagName("a")).shouldBe(CollectionCondition.sizeGreaterThanOrEqual(1));
    dropdownElements.filter(text(title)).shouldHaveSize(1).get(0).shouldBe(visible).click();
    // close the help menu
    if (helpDropdownMenu.parent().$$(Element.DROPDOWN_MENU).size() >= 1) {
        helpDropdownMenu.click();
    }
}
Also used : ElementsCollection(com.codeborne.selenide.ElementsCollection) SelenideElement(com.codeborne.selenide.SelenideElement) When(io.cucumber.java.en.When)

Example 18 with When

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

the class CommonSteps method scrollTo.

/**
 * Scroll the webpage.
 *
 * @param topBottom possible values: top, bottom
 * @param leftRight possible values: left, right
 */
@When("^scroll \"([^\"]*)\" \"([^\"]*)\"$")
public void scrollTo(String topBottom, String leftRight) {
    WebDriver driver = WebDriverRunner.getWebDriver();
    JavascriptExecutor jse = (JavascriptExecutor) driver;
    int x = 0;
    int y = 0;
    Long width = (Long) jse.executeScript("return document.documentElement.scrollWidth");
    Long height = (Long) jse.executeScript("return document.documentElement.scrollHeight");
    if ("right".equals(leftRight)) {
        y = width.intValue();
    }
    if ("bottom".equals(topBottom)) {
        x = height.intValue();
    }
    jse.executeScript("(browserX, browserY) => window.scrollTo(browserX, browserY)", x, y);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) When(io.cucumber.java.en.When)

Example 19 with When

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

the class TodoSteps method createNewTodoApiConnector.

@When("^upload TODO API swagger from URL$")
public void createNewTodoApiConnector() {
    if (OpenShiftUtils.getInstance().getRoute("todo2") == null || !OpenShiftUtils.getInstance().getRoute("todo2").getSpec().getHost().equals("/")) {
        TodoUtils.createDefaultRouteForTodo("todo2", "/");
    }
    String host = "http://" + OpenShiftUtils.getInstance().getRoute("todo2").getSpec().getHost();
    String url = host + "/swagger.json";
    new UploadSwaggerSpecification().upload("url", url);
}
Also used : UploadSwaggerSpecification(io.syndesis.qe.pages.customizations.connectors.wizard.steps.UploadSwaggerSpecification) When(io.cucumber.java.en.When)

Example 20 with When

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

the class TodoSteps method publishMessageFromResourceToDestinationWithName.

@When("^publish JMS message on Todo app page from resource \"([^\"]*)\"$")
public void publishMessageFromResourceToDestinationWithName(String resourceName) {
    log.info("Publish JMS message via Todo app");
    ClassLoader classLoader = this.getClass().getClassLoader();
    URL fileUrl = classLoader.getResource("jms_messages/" + resourceName);
    if (fileUrl == null) {
        fail("File with name " + resourceName + " doesn't exist in the resources");
    }
    File file = new File(fileUrl.getFile());
    try {
        todoPage.setJmsForm(new String(Files.readAllBytes(file.toPath())));
    } catch (IOException e) {
        fail("Error while reading file", e);
    }
    todoPage.sendJmsMessage();
}
Also used : IOException(java.io.IOException) File(java.io.File) URL(java.net.URL) 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