2017-08-04 19:20:31 +00:00
|
|
|
import Cucumber = require("cucumber");
|
|
|
|
import seleniumWebdriver = require("selenium-webdriver");
|
|
|
|
import Assert = require("assert");
|
|
|
|
import Fs = require("fs");
|
|
|
|
import CustomWorld = require("../support/world");
|
|
|
|
|
|
|
|
Cucumber.defineSupportCode(function ({ Given, When, Then }) {
|
|
|
|
Then("I get a notification of type {stringInDoubleQuotes} with message {stringInDoubleQuotes}",
|
2017-09-02 23:25:43 +00:00
|
|
|
{ timeout: 10 * 1000 },
|
2017-08-04 19:20:31 +00:00
|
|
|
function (notificationType: string, notificationMessage: string) {
|
|
|
|
const that = this;
|
|
|
|
const notificationEl = this.driver.findElement(seleniumWebdriver.By.className("notification"));
|
|
|
|
return this.driver.wait(seleniumWebdriver.until.elementIsVisible(notificationEl), 2000)
|
|
|
|
.then(function () {
|
|
|
|
return notificationEl.getText();
|
|
|
|
})
|
|
|
|
.then(function (txt: string) {
|
|
|
|
Assert.equal(notificationMessage, txt);
|
|
|
|
return notificationEl.getAttribute("class");
|
|
|
|
})
|
2017-09-02 23:25:43 +00:00
|
|
|
.then(function (classes: string) {
|
2017-08-04 19:20:31 +00:00
|
|
|
Assert(classes.indexOf(notificationType) > -1, "Class '" + notificationType + "' not found in notification element.");
|
2017-09-03 13:02:38 +00:00
|
|
|
return that.driver.sleep(500);
|
2017-08-04 19:20:31 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|