Search in sources :

Example 1 with ExcludeFromSelectorReports

use of io.syndesis.qe.report.selector.ExcludeFromSelectorReports in project syndesis-qe by syndesisio.

the class CommonSteps method doOAuthValidation.

@ExcludeFromSelectorReports
private void doOAuthValidation(String type) {
    WebDriver driver = WebDriverRunner.getWebDriver();
    // store the current window handle
    String winHandleBefore = driver.getWindowHandle();
    log.info("Current window handle identifier: " + winHandleBefore);
    // close additional browser windows
    if (driver.getWindowHandles().size() > 1) {
        log.error("There is more than one window opened!");
        closeAdditionalBrowserWindows(winHandleBefore);
    }
    // Perform the click operation that opens new window
    clickOnButton("Connect " + type);
    // we need to wait for an oauth window to open after button click
    waitForAdditionalWindow();
    // Switch to new window opened
    for (String winHandle : driver.getWindowHandles()) {
        if (winHandle.equalsIgnoreCase(winHandleBefore)) {
            continue;
        }
        log.info("Found another windows handle: " + winHandle);
        driver.switchTo().window(winHandle);
    }
    // need to wait a bit until window is able to return url
    waitForWindowToShowUrl();
    waitTillPageIsLoaded();
    if ("firefox".equalsIgnoreCase(TestConfiguration.syndesisBrowser())) {
        WebDriverRunner.getWebDriver().manage().window().setSize(new Dimension(1920, 1080));
    }
    switch(type) {
        case "Twitter":
            waitForCallbackRedirect("twitter");
            fillAndValidateTwitter();
            break;
        case "Salesforce":
            waitForCallbackRedirect("salesforce");
            fillAndValidateSalesforce();
            break;
        case "Gmail":
            loginToGoogleIfNeeded("QE Google Mail");
            break;
        case "Google Calendar":
            loginToGoogleIfNeeded("QE Google Calendar");
            break;
        case "SAP Concur":
            waitForCallbackRedirect("concursolutions");
            fillAndValidateConcur();
            break;
        case "Google Sheets":
            loginToGoogleIfNeeded("QE Google Sheets");
            break;
        default:
            fail("Unknown oauth option: " + type);
    }
    // Switch back to original browser (first window)
    driver.switchTo().window(winHandleBefore);
    waitForCallbackRedirect("review");
    // close hanging windows
    closeAdditionalBrowserWindows(winHandleBefore);
    if ("firefox".equalsIgnoreCase(TestConfiguration.syndesisBrowser())) {
        WebDriverRunner.getWebDriver().manage().window().setSize(new Dimension(1920, 1080));
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Dimension(org.openqa.selenium.Dimension) ExcludeFromSelectorReports(io.syndesis.qe.report.selector.ExcludeFromSelectorReports)

Example 2 with ExcludeFromSelectorReports

use of io.syndesis.qe.report.selector.ExcludeFromSelectorReports in project syndesis-qe by syndesisio.

the class ApicurioSteps method verifyOperations.

@ExcludeFromSelectorReports
@Then("^check that apicurio shows (\\d+) imported operations$")
public void verifyOperations(int expectedCount) {
    SelenideElement operations = $(Elements.PAGE_ROOT).shouldBe(visible).find(Elements.NUMBER_OPERATIONS);
    assertThat(operations).isNotNull();
    assertThat(operations.getText()).containsIgnoringCase(Integer.toString(expectedCount)).containsIgnoringCase("operations");
}
Also used : SelenideElement(com.codeborne.selenide.SelenideElement) ExcludeFromSelectorReports(io.syndesis.qe.report.selector.ExcludeFromSelectorReports) Then(io.cucumber.java.en.Then)

Example 3 with ExcludeFromSelectorReports

use of io.syndesis.qe.report.selector.ExcludeFromSelectorReports in project syndesis-qe by syndesisio.

the class ApicurioSteps method removeOperation.

@ExcludeFromSelectorReports
@When("^remove an operation via apicurio gui$")
public void removeOperation() {
    $(Elements.PATH_SECTION).shouldBe(visible).$(Elements.OPERATION).shouldBe(visible).click();
    $(Elements.OPERATION_KEBAB).shouldBe(visible).click();
    SelenideElement kebabMenu = $(Elements.OPERATION_KEBAB_MENU);
    try {
        kebabMenu.$(Elements.OPERATION_KEBAB_MENU_DELETE).shouldBe(visible).click();
    } catch (org.openqa.selenium.StaleElementReferenceException e) {
        $(Elements.OPERATION_KEBAB_MENU).$(Elements.OPERATION_KEBAB_MENU_DELETE).shouldBe(visible).click();
    }
}
Also used : SelenideElement(com.codeborne.selenide.SelenideElement) When(io.cucumber.java.en.When) ExcludeFromSelectorReports(io.syndesis.qe.report.selector.ExcludeFromSelectorReports)

Example 4 with ExcludeFromSelectorReports

use of io.syndesis.qe.report.selector.ExcludeFromSelectorReports in project syndesis-qe by syndesisio.

the class ApicurioSteps method verifyWarnings.

@ExcludeFromSelectorReports
@Then("^check that apicurio shows (\\d+) warnings$")
public void verifyWarnings(int expectedCount) {
    SelenideElement operations = $(Elements.WARNINGS).shouldBe(visible);
    assertThat(operations).isNotNull();
    assertThat(operations.getText()).containsIgnoringCase(Integer.toString(expectedCount));
}
Also used : SelenideElement(com.codeborne.selenide.SelenideElement) ExcludeFromSelectorReports(io.syndesis.qe.report.selector.ExcludeFromSelectorReports) Then(io.cucumber.java.en.Then)

Example 5 with ExcludeFromSelectorReports

use of io.syndesis.qe.report.selector.ExcludeFromSelectorReports in project syndesis-qe by syndesisio.

the class ApicurioSteps method addSecuritySchema.

@ExcludeFromSelectorReports
@When("^add security schema (BASIC|API Key|OAuth 2) via apicurio gui$")
public void addSecuritySchema(String schemeType) {
    // child span element selected so the click is inside of the element
    $(Elements.SECURITY_SECTION).shouldBe(visible).$(By.tagName("span")).click();
    $(Elements.SECURITY_SECTION).shouldBe(visible).$(Elements.BUTTON_ADD_SCHEME).shouldBe(visible).click();
    SelenideElement nameInput = $(SecurityPageElements.NAME).shouldBe(visible);
    try {
        nameInput.sendKeys("ImmovableName");
    } catch (org.openqa.selenium.StaleElementReferenceException e) {
        $(SecurityPageElements.NAME).shouldBe(visible).sendKeys("ImmovableName");
    }
    // select security option
    $(SecurityPageElements.EDITOR).shouldBe(visible).$(SecurityPageElements.SECURITY_TYPE_DROPDOWN).shouldBe(visible).click();
    $(SecurityPageElements.EDITOR).shouldBe(visible).$(SecurityPageElements.SECURITY_DROPDOWN_MENU).shouldBe(visible).$(By.xpath(".//a[contains(text(), \"" + schemeType + "\")]")).shouldBe(visible).click();
    if ("API Key".equalsIgnoreCase(schemeType)) {
        $(By.className("apiKey-auth")).find(By.id("in20")).click();
        $(By.className("apiKey-auth")).findAll("li").filter(text("HTTP header")).first().click();
        $(By.id("name20")).sendKeys("headerName");
    }
    if ("OAuth 2".equalsIgnoreCase(schemeType)) {
        $(By.id("flow")).shouldBe(visible).click();
        $(By.id("flow")).shouldBe(visible).parent().$(By.xpath(".//a[contains(text(), \"Access Code\")]")).shouldBe(visible).click();
        $(By.id("authorizationUrl")).sendKeys("http://syndesis.io");
        $(By.id("tokenUrl")).sendKeys("https://hihi.com");
    }
    ElementsCollection saveButtons = $(SecurityPageElements.ACTION_HEADER).shouldBe(visible).$$(SecurityPageElements.SAVE);
    assertThat(saveButtons.size()).isEqualTo(1);
    saveButtons.get(0).shouldBe(visible).click();
    $(Elements.BUTTON_ADD_REQUIREMENT).shouldBe(visible).click();
    try {
        OpenShiftWaitUtils.waitFor(() -> $(SecurityPageElements.SECURITY_REQUIREMENT).exists(), 60 * 1000L);
    } catch (InterruptedException | TimeoutException e) {
        fail("Security requirement was not found.");
    }
    ElementsCollection items = $$(SecurityPageElements.SECURITY_REQUIREMENT_ITEMS).shouldBe(sizeGreaterThanOrEqual(1)).filterBy(text("ImmovableName"));
    assertThat(items).hasSize(1);
    items.first().click();
    saveButtons = $(SecurityPageElements.ACTION_HEADER).shouldBe(visible).$$(SecurityPageElements.SAVE);
    assertThat(saveButtons.size()).isEqualTo(1);
    saveButtons.get(0).shouldBe(visible).click();
}
Also used : ElementsCollection(com.codeborne.selenide.ElementsCollection) SelenideElement(com.codeborne.selenide.SelenideElement) TimeoutException(java.util.concurrent.TimeoutException) When(io.cucumber.java.en.When) ExcludeFromSelectorReports(io.syndesis.qe.report.selector.ExcludeFromSelectorReports)

Aggregations

ExcludeFromSelectorReports (io.syndesis.qe.report.selector.ExcludeFromSelectorReports)9 SelenideElement (com.codeborne.selenide.SelenideElement)8 Then (io.cucumber.java.en.Then)4 When (io.cucumber.java.en.When)3 ElementsCollection (com.codeborne.selenide.ElementsCollection)1 TimeoutException (java.util.concurrent.TimeoutException)1 Dimension (org.openqa.selenium.Dimension)1 WebDriver (org.openqa.selenium.WebDriver)1