Skip to content

Commit 75574ff

Browse files
reubenmillerDavertMik
authored andcommitted
[Tests] Improving reliability of the CI tests (Travis and Circle CI) (#940)
* Adding chrome headless option when running tests and updating the selenium standalone chrome image * [lint] Added missing semicolon * [Puppeteer] Adding delays after switching tabs in tests * Adding DBUS_SESSION_BUS_ADDRESS=/dev/null to travis environment for the Nightmare because it was timing out sometimes * Refactoring apiDataFactory_test to async/await instead of generators * Removed console message * Added retry to the within acceptence tests * Increased retries to 3 for the within acceptance tests due to it failing in circle ci * Adding a few small delays to Puppeteer Tests when closing tabs * Adding DBUS env variable to circle config due to timeout error * Trigger ci 1 * Trigger ci 2 * Trigger ci 3 * Trigger ci 4 * Trigger ci 5 * Trigger ci 6 * Removed the rest tests from the travis build * Trigger ci 1 * Trigger ci 2 * Removing waitUnitExists tests because it is a duplicate of waitForElement
1 parent 99661ff commit 75574ff

11 files changed

+77
-50
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ addons:
2121
services:
2222
- docker
2323
before_install:
24-
- docker pull selenium/standalone-chrome:3.8
24+
- docker pull selenium/standalone-chrome:3.9.1-actinium
2525
before_script:
26-
- docker run -d --net=host selenium/standalone-chrome:3.8
26+
- docker run -d --net=host --shm-size=2g selenium/standalone-chrome:3.8
27+
- export DBUS_SESSION_BUS_ADDRESS=/dev/null
2728
- export DISPLAY=:99.0
2829
- sh -e /etc/init.d/xvfb start
2930
- chmod -R 777 test/data
@@ -32,5 +33,4 @@ before_script:
3233
- sleep 10
3334
script:
3435
- npm build && npm test
35-
- './node_modules/.bin/mocha test/rest'
3636
- './node_modules/.bin/mocha test/helper/${HELPER}_test.js'

test/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ SITE_URL=http://php:8000
22
SELENIUM_HOST=selenium.chrome
33
SELENIUM_PORT=4444
44
JSON_SERVER_URL=http://json_server:8010
5+
DBUS_SESSION_BUS_ADDRESS=/dev/null

test/acceptance/codecept.WebDriverIO.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ module.exports.config = {
1010
browser: 'chrome',
1111
host: TestHelper.seleniumHost(),
1212
port: TestHelper.seleniumPort(),
13+
desiredCapabilities: {
14+
chromeOptions: {
15+
args: ['--headless', '--disable-gpu', '--window-size=1280,1024'],
16+
},
17+
},
1318
},
1419

1520
},

test/acceptance/within_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Feature('within');
1+
Feature('within', { retries: 3 });
22

33
Scenario('within on form @WebDriverIO @Protractor @Nightmare @Puppeteer', (I) => {
44
I.amOnPage('/form/bug1467');

test/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ services:
6262
- node_modules:/codecept/node_modules
6363

6464
selenium.chrome:
65-
image: selenium/standalone-chrome:3.5.2-antimony
65+
image: selenium/standalone-chrome:3.9.1-actinium
66+
shm_size: 2g
6667
ports:
6768
- 4444:4444
6869

test/helper/ProtractorWeb_test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ describe('Protractor-NonAngular', function () {
3535
restart: false,
3636
seleniumAddress: TestHelper.seleniumAddress(),
3737
waitForTimeout: 5000,
38+
desiredCapabilities: {
39+
chromeOptions: {
40+
args: ['--headless', '--disable-gpu', '--window-size=1280,1024'],
41+
},
42+
},
3843
});
3944
return I._init().then(() => I._beforeSuite().then(() => {
4045
browser = I.browser;

test/helper/Protractor_test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ describe('Protractor', function () {
3434
seleniumAddress: TestHelper.seleniumAddress(),
3535
angular: true,
3636
waitForTimeout: 5000,
37+
desiredCapabilities: {
38+
chromeOptions: {
39+
args: ['--headless', '--disable-gpu', '--window-size=1280,1024'],
40+
},
41+
},
3742
});
3843
return I._init().then(() => I._beforeSuite());
3944
});

test/helper/Puppeteer_test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const siteUrl = TestHelper.siteUrl();
1717

1818
describe('Puppeteer', function () {
1919
this.timeout(35000);
20-
// this.retries(1);
20+
this.retries(1);
2121

2222
before(() => {
2323
global.codecept_dir = path.join(__dirname, '/../data');
@@ -101,14 +101,17 @@ describe('Puppeteer', function () {
101101

102102
describe('#switchToNextTab, #switchToPreviousTab, #openNewTab, #closeCurrentTab, #closeOtherTabs, #grabNumberOfOpenTabs', () => {
103103
it('should only have 1 tab open when the browser starts and navigates to the first page', () => I.amOnPage('/')
104+
.then(() => I.wait(1))
104105
.then(() => I.grabNumberOfOpenTabs())
105106
.then(numPages => assert.equal(numPages, 1)));
106107

107108
it('should switch to next tab', () => I.amOnPage('/info')
109+
.then(() => I.wait(1))
108110
.then(() => I.grabNumberOfOpenTabs())
109111
.then(numPages => assert.equal(numPages, 1))
110112
.then(() => I.click('New tab'))
111113
.then(() => I.switchToNextTab())
114+
.then(() => I.wait(2))
112115
.then(() => I.seeCurrentUrlEquals('/login'))
113116
.then(() => I.grabNumberOfOpenTabs())
114117
.then(numPages => assert.equal(numPages, 2)));
@@ -117,6 +120,7 @@ describe('Puppeteer', function () {
117120
.then(() => I.click('More info'))
118121
.then(() => I.wait(1)) // Wait is required because the url is change by previous statement (maybe related to #914)
119122
.then(() => I.switchToNextTab(2))
123+
.then(() => I.wait(2))
120124
.then(() => assert.equal(true, false, 'Throw an error if it gets this far (which it should not)!'))
121125
.catch((e) => {
122126
assert.equal(e.message, 'There is no ability to switch to next tab with offset 2');
@@ -125,42 +129,52 @@ describe('Puppeteer', function () {
125129
it('should close current tab', () => I.amOnPage('/info')
126130
.then(() => I.click('New tab'))
127131
.then(() => I.switchToNextTab())
132+
.then(() => I.wait(2))
128133
.then(() => I.seeInCurrentUrl('/login'))
129134
.then(() => I.grabNumberOfOpenTabs())
130135
.then(numPages => assert.equal(numPages, 2))
131136
.then(() => I.closeCurrentTab())
137+
.then(() => I.wait(1))
132138
.then(() => I.seeInCurrentUrl('/info'))
133139
.then(() => I.grabNumberOfOpenTabs())
134140
.then(numPages => assert.equal(numPages, 1)));
135141

136142
it('should close other tabs', () => I.amOnPage('/')
137143
.then(() => I.openNewTab())
144+
.then(() => I.wait(1))
138145
.then(() => I.seeInCurrentUrl('about:blank'))
139146
.then(() => I.amOnPage('/info'))
140147
.then(() => I.click('New tab'))
141148
.then(() => I.switchToNextTab())
149+
.then(() => I.wait(2))
142150
.then(() => I.seeInCurrentUrl('/login'))
143151
.then(() => I.closeOtherTabs())
152+
.then(() => I.wait(1))
144153
.then(() => I.seeInCurrentUrl('/login'))
145154
.then(() => I.grabNumberOfOpenTabs())
146155
.then(numPages => assert.equal(numPages, 1)));
147156

148157
it('should open new tab', () => I.amOnPage('/info')
149158
.then(() => I.openNewTab())
159+
.then(() => I.wait(1))
150160
.then(() => I.seeInCurrentUrl('about:blank'))
151161
.then(() => I.grabNumberOfOpenTabs())
152162
.then(numPages => assert.equal(numPages, 2)));
153163

154164
it('should switch to previous tab', () => I.amOnPage('/info')
155165
.then(() => I.openNewTab())
166+
.then(() => I.wait(1))
156167
.then(() => I.seeInCurrentUrl('about:blank'))
157168
.then(() => I.switchToPreviousTab())
169+
.then(() => I.wait(2))
158170
.then(() => I.seeInCurrentUrl('/info')));
159171

160172
it('should assert when there is no ability to switch to previous tab', () => I.amOnPage('/info')
161173
.then(() => I.openNewTab())
174+
.then(() => I.wait(1))
162175
.then(() => I.waitInUrl('about:blank'))
163176
.then(() => I.switchToPreviousTab(2))
177+
.then(() => I.wait(2))
164178
.then(() => I.waitInUrl('/info'))
165179
.catch((e) => {
166180
assert.equal(e.message, 'There is no ability to switch to previous tab with offset 2');
@@ -495,6 +509,7 @@ describe('Puppeteer', function () {
495509
console.log('Test log entry 1');
496510
}))
497511
.then(() => I.openNewTab())
512+
.then(() => I.wait(1))
498513
.then(() => I.amOnPage('/info'))
499514
.then(() => I.executeScript(() => {
500515
console.log('Test log entry 2');

test/helper/WebDriverIO_test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ describe('WebDriverIO', function () {
3131
host: TestHelper.seleniumHost(),
3232
port: TestHelper.seleniumPort(),
3333
waitForTimeout: 5000,
34+
desiredCapabilities: {
35+
chromeOptions: {
36+
args: ['--headless', '--disable-gpu', '--window-size=1280,1024'],
37+
},
38+
},
3439
});
3540
});
3641

test/helper/webapi.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -617,16 +617,6 @@ module.exports.tests = function () {
617617
.then(() => I.seeElementInDOM('//div[@id="step_1"]')));
618618
});
619619

620-
describe('#waitUntilExists', () => {
621-
it('should wait for an element to be removed from DOM', () => I.amOnPage('/spinner')
622-
.then(() => I.waitUntilExists('.loader'))
623-
.then(() => I.dontSeeElement('.loader')));
624-
625-
it('should wait for a non-existing element to be removed from DOM', () => I.amOnPage('/spinner')
626-
.then(() => I.dontSeeElement('.non-existing-class'))
627-
.then(() => I.waitUntilExists('.non-existing-class'))
628-
.then(() => I.dontSeeElement('.non-existing-class')));
629-
});
630620

631621
describe('within tests', () => {
632622
afterEach(() => I._withinEnd());

0 commit comments

Comments
 (0)