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