Fix randomness with integration tests

The notification message pops up and hide after few seconds.
Sometimes, chrome drivers tries to click on a button that moves due
to the notification message animation and thus miss it.
This commit is contained in:
Clement Michaud 2017-10-08 16:28:10 +02:00
parent 267cf2921d
commit 54c93fc945
3 changed files with 11 additions and 1 deletions

View File

@ -8,6 +8,7 @@ Feature: User is correctly redirected
Scenario: User is redirected to home page after several authentication tries
When I visit "https://public.test.local:8080/secret.html"
And I login with user "john" and password "badpassword"
And I wait for notification to disappear
And I clear field "username"
And I login with user "john" and password "password"
And I use "REGISTERED" as TOTP token handle

View File

@ -11,6 +11,15 @@ Cucumber.defineSupportCode(function ({ Given, When, Then }) {
return this.visit(link);
});
When("I wait for notification to disappear", function() {
const that = this;
const notificationEl = this.driver.findElement(seleniumWebdriver.By.className("notification"));
return this.driver.wait(seleniumWebdriver.until.elementIsVisible(notificationEl), 15000)
.then(function() {
return that.driver.wait(seleniumWebdriver.until.elementIsNotVisible(notificationEl), 15000);
})
})
When("I set field {stringInDoubleQuotes} to {stringInDoubleQuotes}", function (fieldName: string, content: string) {
return this.setFieldTo(fieldName, content);
});

View File

@ -10,7 +10,7 @@ Cucumber.defineSupportCode(function ({ Given, When, Then }) {
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)
return this.driver.wait(seleniumWebdriver.until.elementIsVisible(notificationEl), 5000)
.then(function () {
return notificationEl.getText();
})