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.");
}
}
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();
}
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()));
}
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);
}
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);
}
});
}
Aggregations