Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1647 Remove PhantomJS from E2E test, and use Chrom Headless Webdriver #1648

Merged
merged 3 commits into from
Dec 25, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-polyfill": "^6.22.0",
"babel-preset-env": "^1.5.1",
"chromedriver": "^2.45.0",
"chromedriver": "^78.0.1",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"css-loader": "^2.1.0",
Expand All @@ -54,13 +54,11 @@
"express": "^4.14.1",
"jasmine": "2.8.0",
"jasmine-core": "2.8.0",
"nightwatch": "^0.9.12",
"nightwatch": "^1.2.4",
"nightwatch-helpers": "^1.2.0",
"phantomjs-prebuilt": "^2.1.14",
"rollup": "^1.1.0",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-replace": "^2.1.0",
"selenium-server": "^2.53.1",
"terser": "^3.17.0",
"todomvc-app-css": "^2.1.0",
"typescript": "^3.7.2",
Expand Down
29 changes: 10 additions & 19 deletions test/e2e/nightwatch.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ module.exports = {
'custom_commands_path': ['node_modules/nightwatch-helpers/commands'],
'custom_assertions_path': ['node_modules/nightwatch-helpers/assertions'],

'selenium': {
'start_process': true,
'server_path': require('selenium-server').path,
'host': '127.0.0.1',
'port': 4444,
'cli_args': {
'webdriver.chrome.driver': require('chromedriver').path
}
'webdriver': {
'start_process': true
},

'test_settings': {
'default': {
'selenium_port': 4444,
'selenium_host': 'localhost',
'silent': true,
'screenshots': {
'enabled': true,
Expand All @@ -29,19 +21,18 @@ module.exports = {
},

'chrome': {
'desiredCapabilities': {
'browserName': 'chrome',
'javascriptEnabled': true,
'acceptSslCerts': true
}
},
'webdriver': {
'port': 9515,
'server_path': require('chromedriver').path
},

'phantomjs': {
'desiredCapabilities': {
'browserName': 'phantomjs',
'browserName': 'chrome',
'javascriptEnabled': true,
'acceptSslCerts': true,
'phantomjs.binary.path': require('phantomjs-prebuilt').path
'chromeOptions': {
'args': ['--headless']
}
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions test/e2e/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ if (args.indexOf('--config') === -1) {
args = args.concat(['--config', 'test/e2e/nightwatch.config.js'])
}
if (args.indexOf('--env') === -1) {
args = args.concat(['--env', 'phantomjs'])
args = args.concat(['--env', 'chrome'])
}
var i = args.indexOf('--test')
if (i > -1) {
args[i + 1] = 'test/e2e/specs/' + args[i + 1]
}
if (args.indexOf('phantomjs') > -1) {
process.env.PHANTOMJS = true
}

var runner = spawn('./node_modules/.bin/nightwatch', args, {
stdio: 'inherit'
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
.assert.containsText('.cart', 'H&M T-Shirt White - $10.99 x 1')
.assert.containsText('.cart', 'Total: $1,011.01')
.click('.cart button')
.waitFor(120)
.waitFor(200)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to change this because test was failing... Not sure why.

.assert.containsText('.cart', 'Please add some products to cart')
.assert.containsText('.cart', 'Total: $0.00')
.assert.containsText('.cart', 'Checkout successful')
Expand Down
10 changes: 8 additions & 2 deletions test/e2e/specs/todomvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = {
.dblClick('.todo:nth-child(1) label')
.assert.count('.todo.editing', 1)
.assert.focused('.todo:nth-child(1) .edit')
.clearValue('.todo:nth-child(1) .edit')
deleteValue('.todo:nth-child(1) .edit', 'test2')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clearValue was not working. Not sure why but after clearValue, 2 todos was removed before setValue. So I'm guessing clearValue is emitting blur event or something...

So, I went ahead and created deleteValue function which will input "backspace" and deletes value. If this is the only workaround we have at the moment, I would like to extract that into a custom command so that we can do browser.deleteValue. Ref: Custom Command Doc

.setValue('.todo:nth-child(1) .edit', 'edited!')
.click('footer') // blur
.assert.count('.todo.editing', 0)
Expand All @@ -114,14 +114,15 @@ module.exports = {
// editing triggered by enter
browser
.dblClick('.todo label')
deleteValue('.todo:nth-child(1) .edit', 'edited!')
.enterValue('.todo:nth-child(1) .edit', 'edited again!')
.assert.count('.todo.editing', 0)
.assert.containsText('.todo:nth-child(1) label', 'edited again!')

// cancel
browser
.dblClick('.todo label')
.clearValue('.todo:nth-child(1) .edit')
deleteValue('.todo:nth-child(1) .edit', 'edited again!')
.setValue('.todo:nth-child(1) .edit', 'edited!')
.trigger('.todo:nth-child(1) .edit', 'keyup', 27)
.assert.count('.todo.editing', 0)
Expand All @@ -130,6 +131,7 @@ module.exports = {
// empty value should remove
browser
.dblClick('.todo label')
deleteValue('.todo:nth-child(1) .edit', 'edited again!')
.enterValue('.todo:nth-child(1) .edit', ' ')
.assert.count('.todo', 3)

Expand All @@ -150,5 +152,9 @@ module.exports = {
.moveToElement('.todo:nth-child(' + n + ')', 10, 10)
.click('.todo:nth-child(' + n + ') .destroy')
}

function deleteValue (el, text) {
return browser.setValue(el, text.split('').map(() => '\u0008'))
}
}
}
Loading