derby-webdriverio
Webdriver.io for Derby.js
Installation
npm i --save derby-webdriverio
Usage
In your derby app index file:
# app/index.coffee
app = require('derby').createApp 'foobar', __filename
window.app = app if window? # app must be accessible from the client
app.use require('derby-webdriverio/renderReady')
Create wdio.conf.js
in project's root folder:
exports.config = require('derby-webdriverio')({
browsers: {
browser: 1,
prof: 1,
students: 10
},
desiredCapabilities: {
browserName: 'chrome'
},
baseUrl: 'http://localhost:3003',
waitforTimeout: 30000,
screenshotPath: __dirname + '/test/screenshots/',
specs: [
'./test/e2e/**/*.js',
'./test/e2e/**/*.coffee'
],
exclude: [
'./test/e2e/**/_*.js',
'./test/e2e/**/_*.coffee'
]
})
To run your tests:
./node_modules/.bin/wdio
If you want to run it as npm test
you can add the following script to your package.json
:
"scripts": {
"test": "wdio",
},
.*AndWait()
These methods accept the same arguments as the original methods.
They do the same action and wait for derby page to fully load after that.
.urlAndWait()
.clickAndWait()
.submitFormAndWait()
model
All racer get-
and set-
methods are available.
Couple of examples:
.modelGet()
browser
.modelGet '_session.userId'
.then (userId) ->
@urlAndWait '/profile/' + userId
.modelSet()
it 'check title', ->
newTitle = 'New Title'
prevTitle = yield browser.modelSet '_page.title', newTitle
browser.getTitle()
.then (title) ->
title.should.not.equal prevTitle
title.should.equal newTitle
all other get/set methods are supported -- .modelAdd
, .modelPop
, etc.
history
.historyPush(path)
Do app.history.push
on the client and wait for the page to fully load.
browser
.historyPush '/profile'
.getTitle()
.should.eventually.equal 'My Profile'
.historyRefresh()
Refresh the page using app.history.refresh
on the client.
X()
- XPath function
XPath helper function, provides better support for querying text nodes.
Available globally as X
X([selector], text)
Returns an XPath selector to find a node which holds text
.
Optionally you can specify a CSS3 selector to narrow the lookup.
browser
# Click on a `<button>` within `<form class='main'>` that has `Submit` text.
.click X 'form.main button', 'Submit'
Chai shorthands
A bunch of useful shorthand methods to test things.
All of them accept the arguments which will be passed to X()
function.
shouldExist()
browser
# Note that the arguments passed here are `X()` function arguments
.shouldExist 'form.main button', 'Submit'
.shouldExist 'Welcome to my Website'
shouldNotExist()
shouldBeVisible()
shouldNotBeVisible()
shouldExecute
Accepts the same arguments as .execute()
and checks that its return value
equals true