Skip to content

Commit bfb3361

Browse files
author
Christoph Wolfes
committed
updates selenium webdriver which removes promise manager
the selenium driver now returns a promise instead of doing some crazy stack-magic. see this issue for more information: SeleniumHQ/selenium#2969
1 parent 9500405 commit bfb3361

8 files changed

+84
-90
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ node('vagrant') {
8383

8484
dir('integrationTests') {
8585

86-
docker.image('node:8.7.0-stretch').inside("-e WEBDRIVER=remote -e CES_FQDN=${cesIP} -e SELENIUM_BROWSER=chrome -e SELENIUM_REMOTE_URL=http://${seleniumChromeIP}:4444/wd/hub") {
86+
docker.image('node:8-stretch').inside("-e WEBDRIVER=remote -e CES_FQDN=${cesIP} -e SELENIUM_BROWSER=chrome -e SELENIUM_REMOTE_URL=http://${seleniumChromeIP}:4444/wd/hub") {
8787
sh 'yarn install'
8888
sh 'yarn run ci-test'
8989
}

integrationTests/adminFunctions.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ module.exports = class AdminFunctions{
5555
};
5656

5757
async giveAdminRights(){
58-
5958
await request(config.baseUrl)
6059
.put('/usermgt/api/users/' + this.testuserName)
6160
.auth(config.username, config.password)
@@ -72,28 +71,31 @@ module.exports = class AdminFunctions{
7271
};
7372

7473
async giveAdminRightsInRedmine(){
75-
utils.login(this.driver, '/redmine');
76-
this.driver.get(config.baseUrl + '/redmine/users');
74+
await utils.login(this.driver, '/redmine');
75+
await this.driver.get(config.baseUrl + '/redmine/users');
7776

78-
this.driver.wait(until.elementLocated(By.linkText(this.testuserName)), 5000);
79-
this.driver.findElement(By.linkText(this.testuserName)).click();
80-
this.driver.wait(until.elementLocated(By.css('input[type="checkbox"]')), 5000);
77+
await this.driver.wait(until.elementLocated(By.linkText(this.testuserName)), 5000);
78+
await this.driver.findElement(By.linkText(this.testuserName)).click();
79+
await this.driver.wait(until.elementLocated(By.css('input[type="checkbox"]')), 5000);
8180
var buttonEnabled = await this.driver.findElement(By.css('input#user_admin')).isSelected();
82-
if(!buttonEnabled) this.driver.findElement(By.css('input#user_admin')).click();
81+
if(!buttonEnabled) {
82+
await this.driver.findElement(By.css('input#user_admin')).click();
83+
}
8384
await this.driver.findElement(By.css('input[type="submit"]')).click();
8485
await this.driver.wait(until.elementLocated(By.css('a.logout')), 5000);
8586
await this.driver.findElement(By.css('a.logout')).click();
8687
};
8788

8889
async takeAdminRightsInRedmine(){
89-
utils.login(this.driver, '/redmine');
90-
this.driver.get(config.baseUrl + '/redmine/users');
91-
92-
this.driver.wait(until.elementLocated(By.linkText(this.testuserName)), 5000);
93-
this.driver.findElement(By.linkText(this.testuserName)).click();
94-
this.driver.wait(until.elementLocated(By.css('input#user_admin')), 5000);
90+
await utils.login(this.driver, '/redmine');
91+
await this.driver.get(config.baseUrl + '/redmine/users');
92+
await this.driver.wait(until.elementLocated(By.linkText(this.testuserName)), 5000);
93+
await this.driver.findElement(By.linkText(this.testuserName)).click();
94+
await this.driver.wait(until.elementLocated(By.css('input#user_admin')), 5000);
9595
var buttonEnabled = await this.driver.findElement(By.css('input#user_admin')).isSelected();
96-
if(buttonEnabled) this.driver.findElement(By.css('input#user_admin')).click();
96+
if(buttonEnabled){
97+
await this.driver.findElement(By.css('input#user_admin')).click();
98+
}
9799
await this.driver.findElement(By.css('input[type="submit"]')).click();
98100
await this.driver.wait(until.elementLocated(By.css('a.logout')), 5000);
99101
await this.driver.findElement(By.css('a.logout')).click();
@@ -119,11 +121,11 @@ module.exports = class AdminFunctions{
119121

120122
async testuserLogin() {
121123

122-
this.driver.get(config.baseUrl + '/redmine');
123-
this.driver.wait(until.elementLocated(By.id('username')), 5000);
124-
this.driver.findElement(By.id('username')).sendKeys(this.testuserName);
125-
this.driver.findElement(By.id('password')).sendKeys(this.testuserPasswort);
126-
this.driver.findElement(By.css('input[name="submit"]')).click();
124+
await this.driver.get(config.baseUrl + '/redmine');
125+
await this.driver.wait(until.elementLocated(By.id('username')), 5000);
126+
await this.driver.findElement(By.id('username')).sendKeys(this.testuserName);
127+
await this.driver.findElement(By.id('password')).sendKeys(this.testuserPasswort);
128+
await this.driver.findElement(By.css('input[name="submit"]')).click();
127129
};
128130

129131
async testuserLogout() {
@@ -156,9 +158,9 @@ module.exports = class AdminFunctions{
156158

157159
async getApiKeyOfTestuser(){
158160

159-
this.testuserLogin();
160-
this.driver.get(config.baseUrl + config.redmineContextPath + '/my/api_key');
161-
this.driver.wait(until.elementLocated(By.css('div.box pre')), 5000);
161+
await this.testuserLogin();
162+
await this.driver.get(config.baseUrl + config.redmineContextPath + '/my/api_key');
163+
await this.driver.wait(until.elementLocated(By.css('div.box pre')), 5000);
162164
const apiKey = await this.driver.findElement(By.css('div.box pre')).getText();
163165
await this.testuserLogout();
164166
return apiKey;

integrationTests/administration-rest.spec.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
const request = require('supertest');
21
const config = require('./config');
32
const AdminFunctions = require('./adminFunctions');
43
const utils = require('./utils');
54
const webdriver = require('selenium-webdriver');
6-
const By = webdriver.By;
7-
const keys = webdriver.Key;
8-
const until = webdriver.until;
95

106
jest.setTimeout(30000);
117
let driver;
@@ -29,9 +25,8 @@ afterEach(async() => {
2925
describe('administration rest tests', () => {
3026

3127
test('rest - user is admin in general = admin in redmine', async() => {
32-
adminFunctions.giveAdminRights();
28+
await adminFunctions.giveAdminRights();
3329
const apiKey = await adminFunctions.getApiKeyOfTestuser();
34-
3530
await adminFunctions.accessUsersJson(apiKey, 200);
3631
});
3732

@@ -42,46 +37,42 @@ describe('administration rest tests', () => {
4237

4338
test('rest - user gets admin rights in redmine', async() => {
4439

45-
adminFunctions.testuserLogin(); // test user login to update information in redmine
40+
await adminFunctions.testuserLogin(); // test user login to update information in redmine
4641
await adminFunctions.testuserLogout();
4742
await adminFunctions.giveAdminRightsInRedmine();
4843
const apiKey = await adminFunctions.getApiKeyOfTestuser();
49-
5044
await adminFunctions.accessUsersJson(apiKey, 200);
5145
});
5246

5347
test('rest - user gets admin rights in redmine and then in usermanagement = take rights in usermanagement', async() => {
5448

55-
adminFunctions.testuserLogin(); // test user login to update information in redmine
49+
await adminFunctions.testuserLogin(); // test user login to update information in redmine
5650
await adminFunctions.testuserLogout();
5751
await adminFunctions.giveAdminRightsInRedmine();
58-
adminFunctions.giveAdminRights();
59-
adminFunctions.takeAdminRights();
52+
await adminFunctions.giveAdminRights();
53+
await adminFunctions.takeAdminRights();
6054
const apiKey = await adminFunctions.getApiKeyOfTestuser();
61-
6255
await adminFunctions.accessUsersJson(apiKey, 200);
6356
});
6457

6558
test('rest - user gets admin rights in redmine = take rights in redmine', async() => {
6659

67-
adminFunctions.testuserLogin(); // test user login to update information in redmine
60+
await adminFunctions.testuserLogin(); // test user login to update information in redmine
6861
await adminFunctions.testuserLogout();
6962
await adminFunctions.giveAdminRightsInRedmine();
7063
await adminFunctions.takeAdminRightsInRedmine();
7164
const apiKey = await adminFunctions.getApiKeyOfTestuser();
72-
7365
await adminFunctions.accessUsersJson(apiKey, 403);
7466
});
7567

7668
test('rest - user gets admin rights in redmine and then in usermanagement = take rights in redmine', async() => {
7769

78-
adminFunctions.testuserLogin(); // test user login to update information in redmine
70+
await adminFunctions.testuserLogin(); // test user login to update information in redmine
7971
await adminFunctions.testuserLogout();
8072
await adminFunctions.giveAdminRightsInRedmine();
81-
adminFunctions.giveAdminRights();
73+
await adminFunctions.giveAdminRights();
8274
await adminFunctions.takeAdminRightsInRedmine();
8375
const apiKey = await adminFunctions.getApiKeyOfTestuser();
84-
8576
await adminFunctions.accessUsersJson(apiKey, 200);
8677
});
8778

integrationTests/administration.spec.js

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ let adminFunctions;
1414
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
1515

1616
beforeEach(async() => {
17-
driver = utils.createDriver(webdriver);
18-
17+
driver = await utils.createDriver(webdriver);
1918
adminFunctions = new AdminFunctions(driver, 'testUser', 'testUser', 'testUser', '[email protected]', 'testuserpasswort');
2019
await adminFunctions.createUser();
2120
});
2221

2322
afterEach(async() => {
24-
driver.findElement(By.css('a.logout')).click();
23+
await driver.findElement(By.css('a.logout')).click();
2524
await adminFunctions.removeUser();
2625
await driver.quit();
2726
});
@@ -30,68 +29,68 @@ describe('administration rights', () => {
3029

3130
test('user is admin in general = admin in redmine', async() => {
3231

33-
adminFunctions.giveAdminRights();
34-
adminFunctions.testuserLogin();
32+
await adminFunctions.giveAdminRights();
33+
await adminFunctions.testuserLogin();
3534
var adminrights = await adminFunctions.isAdministratorInRedmine();
3635
expect(adminrights).toBe(true);
3736

3837
});
3938

4039
test('user is no admin in general = no admin in redmine', async() => {
4140

42-
adminFunctions.testuserLogin();
41+
await adminFunctions.testuserLogin();
4342
var adminrights = await adminFunctions.isAdministratorInRedmine();
4443
expect(adminrights).toBe(false);
4544
});
4645

4746
test('user gets admin rights in redmine', async() => {
4847

49-
adminFunctions.testuserLogin(); // test user login to update information in redmine
50-
driver.wait(until.elementLocated(By.css('a.logout')), 5000);
51-
driver.findElement(By.css('a.logout')).click();
48+
await adminFunctions.testuserLogin(); // test user login to update information in redmine
49+
await driver.wait(until.elementLocated(By.css('a.logout')), 5000);
50+
await driver.findElement(By.css('a.logout')).click();
5251
await adminFunctions.giveAdminRightsInRedmine();
53-
adminFunctions.testuserLogin();
52+
await adminFunctions.testuserLogin();
5453
var adminrights = await adminFunctions.isAdministratorInRedmine();
5554
expect(adminrights).toBe(true);
5655

5756
});
5857

5958
test('user gets admin rights in redmine and then in usermanagement = take rights in usermanagement', async() => {
6059

61-
adminFunctions.testuserLogin(); // test user login to update information in redmine
62-
driver.wait(until.elementLocated(By.css('a.logout')), 5000);
63-
driver.findElement(By.css('a.logout')).click();
60+
await adminFunctions.testuserLogin(); // test user login to update information in redmine
61+
await driver.wait(until.elementLocated(By.css('a.logout')), 5000);
62+
await driver.findElement(By.css('a.logout')).click();
6463
await adminFunctions.giveAdminRightsInRedmine();
65-
adminFunctions.giveAdminRights();
66-
adminFunctions.takeAdminRights();
67-
adminFunctions.testuserLogin();
64+
await adminFunctions.giveAdminRights();
65+
await adminFunctions.takeAdminRights();
66+
await adminFunctions.testuserLogin();
6867
var adminrights = await adminFunctions.isAdministratorInRedmine();
6968
expect(adminrights).toBe(true);
7069

7170
});
7271

7372
test('user gets admin rights in redmine = take rights in redmine', async() => {
7473

75-
adminFunctions.testuserLogin(); // test user login to update information in redmine
76-
driver.wait(until.elementLocated(By.css('a.logout')), 5000);
77-
driver.findElement(By.css('a.logout')).click();
74+
await adminFunctions.testuserLogin(); // test user login to update information in redmine
75+
await driver.wait(until.elementLocated(By.css('a.logout')), 5000);
76+
await driver.findElement(By.css('a.logout')).click();
7877
await adminFunctions.giveAdminRightsInRedmine();
7978
await adminFunctions.takeAdminRightsInRedmine();
80-
adminFunctions.testuserLogin();
79+
await adminFunctions.testuserLogin();
8180
var adminrights = await adminFunctions.isAdministratorInRedmine();
8281
expect(adminrights).toBe(false);
8382

8483
});
8584

8685
test('user gets admin rights in redmine and then in usermanagement = take rights in redmine', async() => {
8786

88-
adminFunctions.testuserLogin(); // test user login to update information in redmine
89-
driver.wait(until.elementLocated(By.css('a.logout')), 5000);
90-
driver.findElement(By.css('a.logout')).click();
87+
await adminFunctions.testuserLogin(); // test user login to update information in redmine
88+
await driver.wait(until.elementLocated(By.css('a.logout')), 5000);
89+
await driver.findElement(By.css('a.logout')).click();
9190
await adminFunctions.giveAdminRightsInRedmine();
92-
adminFunctions.giveAdminRights();
91+
await adminFunctions.giveAdminRights();
9392
await adminFunctions.takeAdminRightsInRedmine();
94-
adminFunctions.testuserLogin();
93+
await adminFunctions.testuserLogin();
9594
var adminrights = await adminFunctions.isAdministratorInRedmine();
9695
expect(adminrights).toBe(true);
9796

integrationTests/cas-browser.spec.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,49 @@ afterEach(() => {
2222
describe('cas browser tests', () => {
2323

2424
test('redirect to cas authentication', async() => {
25-
driver.get(config.baseUrl + config.redmineContextPath);
25+
await driver.get(config.baseUrl + config.redmineContextPath);
2626
const url = await driver.getCurrentUrl();
27-
2827
expectations.expectCasLogin(url);
2928
});
3029

3130
test('cas authentication', async() => {
32-
utils.login(driver, config.redmineContextPath);
31+
await utils.login(driver, config.redmineContextPath);
32+
await driver.wait(until.elementLocated(By.css('#loggedas a.user')), 5000);
3333
const username = await driver.findElement(By.css('#loggedas a.user')).getText();
34-
3534
expect(username).toBe(config.username);
3635
});
3736

3837
test('check cas attributes', async() => {
39-
utils.login(driver, config.redmineContextPath);
40-
driver.findElement(By.css('#account a.my-account')).click();
41-
42-
const firstname = await driver.findElement(By.id('user_firstname')).getAttribute('value');
38+
await utils.login(driver, config.redmineContextPath);
39+
await driver.wait(until.elementLocated(By.css('#account a.my-account')), 5000);
40+
await driver.findElement(By.css('#account a.my-account')).click();
41+
let firstname = await driver.findElement(By.id('user_firstname'));
42+
firstname = await firstname.getAttribute('value');
4343
expect(firstname).toBe(config.firstname);
4444

45-
const lastname = await driver.findElement(By.id('user_lastname')).getAttribute('value');
45+
let lastname = await driver.findElement(By.id('user_lastname'));
46+
lastname = await lastname.getAttribute('value');
4647
expect(lastname).toBe(config.lastname);
4748

48-
const email = await driver.findElement(By.id('user_mail')).getAttribute('value');
49+
let email = await driver.findElement(By.id('user_mail'));
50+
email = await email.getAttribute('value');
4951
expect(email).toBe(config.email);
5052
});
5153

5254
test('front channel logout', async() => {
53-
utils.login(driver, config.redmineContextPath);
54-
driver.findElement(By.css('a.logout')).click();
55+
await utils.login(driver, config.redmineContextPath);
56+
await driver.wait(until.elementLocated(By.css('a.logout')), 5000);
57+
await driver.findElement(By.css('a.logout')).click();
5558
const url = await driver.getCurrentUrl();
5659

5760
expectations.expectCasLogout(url);
5861
});
5962

6063
test('back channel logout', async() => {
61-
utils.login(driver, config.redmineContextPath);
62-
driver.get(config.baseUrl + '/cas/logout');
63-
driver.get(config.baseUrl + config.redmineContextPath);
64+
await utils.login(driver, config.redmineContextPath);
65+
await driver.get(config.baseUrl + '/cas/logout');
66+
await driver.get(config.baseUrl + config.redmineContextPath);
6467
const url = await driver.getCurrentUrl();
65-
6668
expectations.expectCasLogin(url);
6769
});
6870

integrationTests/cas-rest.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ describe('cas rest tests', () => {
2323

2424
test('authenticate with API key', async() => {
2525

26-
const driver = utils.createDriver(webdriver);
27-
utils.login(driver, config.redmineContextPath + '/my/api_key');
28-
driver.wait(until.elementLocated(By.css('div.box pre')), 5000);
26+
const driver = await utils.createDriver(webdriver);
27+
await utils.login(driver, config.redmineContextPath + '/my/api_key');
28+
await driver.wait(until.elementLocated(By.css('div.box pre')), 5000);
2929
const apiKey = await driver.findElement(By.css('div.box pre')).getText();
3030
driver.quit();
3131

integrationTests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"chromedriver": "^2.33.2",
1111
"jest": "^21.2.1",
1212
"jest-junit": "^3.1.0",
13-
"selenium-webdriver": "^3.6.0",
13+
"selenium-webdriver": "4.0.0-alpha.1",
1414
"supertest": "^3.0.0"
1515
},
1616
"jest-junit": {

integrationTests/utils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ function createLocalDriver() {
2121
.build();
2222
}
2323

24-
exports.login = function(driver, relativeUrl) {
25-
driver.get(config.baseUrl + relativeUrl);
26-
driver.findElement(By.id('username')).sendKeys(config.username);
27-
driver.findElement(By.id('password')).sendKeys(config.password);
28-
driver.findElement(By.css('input[name="submit"]')).click();
24+
exports.login = async function(driver, relativeUrl) {
25+
await driver.get(config.baseUrl + relativeUrl);
26+
await driver.findElement(By.id('username')).sendKeys(config.username);
27+
await driver.findElement(By.id('password')).sendKeys(config.password);
28+
await driver.findElement(By.css('input[name="submit"]')).click();
2929
};

0 commit comments

Comments
 (0)