Evan You
9 years ago
4 changed files with 83 additions and 9 deletions
@ -0,0 +1,18 @@ |
|||
exports.assertion = function (selector, attr) { |
|||
this.message = 'Testing if element <' + selector + '> has attribute ' + attr + '.' |
|||
this.expected = true |
|||
this.value = function (res) { |
|||
return res.value |
|||
} |
|||
this.pass = function (val) { |
|||
return val === this.expected |
|||
} |
|||
this.command = function (cb) { |
|||
var self = this |
|||
return this.api.execute(function (selector, attr) { |
|||
return document.querySelector(selector).hasAttribute(attr) |
|||
}, [selector, attr], function (res) { |
|||
cb.call(self, res) |
|||
}) |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
module.exports = { |
|||
'select2': function (browser) { |
|||
browser |
|||
.url('http://localhost:8080/examples/select2/') |
|||
.waitForElementVisible('.select2', 1000) |
|||
.assert.elementPresent('select') |
|||
.assert.containsText('p', 'Selected: 0') |
|||
.assert.containsText('span.select2', 'Select one') |
|||
|
|||
.click('span.select2') |
|||
.assert.elementCount('.select2-results__option', 3) |
|||
.assert.containsText('.select2-results__option:nth-child(1)', 'Select one') |
|||
.assert.containsText('.select2-results__option:nth-child(2)', 'Hello') |
|||
.assert.containsText('.select2-results__option:nth-child(3)', 'World') |
|||
.assert.attributePresent('.select2-results__option:nth-child(1)', 'aria-disabled') |
|||
|
|||
.click('.select2-results__option:nth-child(2)') |
|||
.assert.elementCount('.select2-results__option', 0) |
|||
.assert.containsText('p', 'Selected: 1') |
|||
.assert.containsText('span.select2', 'Hello') |
|||
|
|||
// test dynamic options
|
|||
.execute(function () { |
|||
vm.options.push({ id: 3, text: 'Vue' }) |
|||
}) |
|||
.click('span.select2') |
|||
.assert.elementCount('.select2-results__option', 4) |
|||
.assert.containsText('.select2-results__option:nth-child(1)', 'Select one') |
|||
.assert.containsText('.select2-results__option:nth-child(2)', 'Hello') |
|||
.assert.containsText('.select2-results__option:nth-child(3)', 'World') |
|||
.assert.containsText('.select2-results__option:nth-child(4)', 'Vue') |
|||
|
|||
.click('.select2-results__option:nth-child(4)') |
|||
.assert.elementCount('.select2-results__option', 0) |
|||
.assert.containsText('p', 'Selected: 3') |
|||
.assert.containsText('span.select2', 'Vue') |
|||
|
|||
.execute(function () { |
|||
vm.selected = 2 |
|||
}) |
|||
.assert.containsText('p', 'Selected: 2') |
|||
.assert.containsText('span.select2', 'World') |
|||
.end() |
|||
} |
|||
} |
Loading…
Reference in new issue