Contenu connexe Similaire à JS Fest 2018. Сергей Пузанков. E2E-тестирование фронтенда c Hermione (20) JS Fest 2018. Сергей Пузанков. E2E-тестирование фронтенда c Hermione22. RUNS TESTS IN PARALLEL
▸If you have grid with 10 browsers You could
run in 10 bowsers 10 sessions in each. So
you could run 100 tests in parallel.
23. EASY TO START AND USE
▸Just 1 small config and 1 test file to start.
▸All WebriverIO methods available for use.
34. TEST
const assert = require(‘chai’).assert;
const pageUrl = 'https://github.com/gemini-testing/hermione';
describe('github', function() {
it('should find hermione', function() {
return this.browser
.url(pageUrl)
.getText('#readme h1')
.then(function(title) {
assert.equal(title, 'Hermione')
});
});
});
40. describe('Page loaded', function() {
it('should have title', function() {
return this.browser
.url(url.root)
.getText('.header h1')
.then(function(text) {
assert.equal(text, 'todos')
});
});
it('should have example type title', function() {
return this.browser
.url(url.root)
.getText('.source-links h5')
.then(function(text) {
assert.equal(text, ‘Vanilla JavaScript Example')
});
});
});
PAGE LOADED
41. describe('New todo input', function() {
it('should have input with placeholder', function() {
return this.browser
.url(url.root)
.getAttribute('.new-todo', 'placeholder')
.then(function(text) {
assert.equal(text, 'What needs to be done?')
});
});
});
GET ATTRIBUTE
42. describe('Add new todo', function() {
beforeEach(function (done) {
return this.browser
.url(url.root)
.localStorage('DELETE', { key: 'todos-vanillajs' })
.then(function() {
done();
})
});
it('should add new todo', function() {
return this.browser
.url(url.root)
.setValue('.new-todo', 'Clean up the room')
.keys('Enter')
.getText('.todo-list li:nth-child(1) .view label')
.then(function(text) {
assert.equal(text, 'Clean up the room')
});
});
});
BEFORE EACH
44. describe('Add new todo', function() {
it('should add new todo', function() {
return this.browser
.url(url.root)
.setValue('.new-todo', 'Clean up the room')
.keys(‘Enter’)
.saveScreenshot(‘./debug/client/debug.png’)
.getText('.todo-list li:nth-child(1) .view label')
.then(function(text) {
assert.equal(text, 'Clean up the room')
});
});
});
DEBUG
45. describe('Add new todo', function() {
it('should add new todo', function() {
return this.browser
.url(url.root)
.setValue(‘.new-todo', 'Clean up the room')
.keys(‘Enter’)
.debug()
.getText('.todo-list li:nth-child(1) .view label')
.then(function(text) {
assert.equal(text, 'Clean up the room')
});
});
});
DEBUG
47. describe('Remove items', function() {
beforeEach(function (done) {
return this.browser
.url(url.root)
.localStorage('POST', { key: 'todos-vanillajs', value: '{"todos":[]}' })
.setValue(pageObject.mainInput, 'Clean up the room')
.click(pageObject.mainHeader)
.setValue(pageObject.mainInput, 'Check email')
.click(pageObject.mainHeader)
.then(function() {
done();
})
});
it('should remove item', function() {
return this.browser
.click(pageObject.labelOfFirstItem)
.click(pageObject.destroyFirstItem)
.getText(pageObject.labelOfFirstItem)
.then(function(text) {
assert.equal(text, 'Check email')
});
});
});
PREPARE DATA
51. module.exports = {
mainHeader: '.header h1',
exampleType: '.source-links h5',
mainInput: '.new-todo',
labelOfFirstItem: '.todo-list li:nth-child(1) .view label',
counterNumber: '.todo-count strong',
destroyFirstItem: '.todo-list li:nth-child(1) .destroy'
};
PAGE OBJECT
describe('New todo input', function() {
it('should have input with placeholder', function() {
return this.browser
.url(url.root)
.getAttribute(pageObject.mainInput, 'placeholder')
.then(function(text) {
assert.equal(text, 'Pls enter task')
});
});
});
53. it('should add new todo', function() {
return this.browser
.url(url.root)
.setValue(pageObject.mainInput, texts.todoLine1)
.keys('Enter')
.getText(pageObject.labelOfFirstItem)
.then(function(text) {
assert.equal(text, texts.todoLine1)
});
});
L10N
{
"inputPlaceHolder": "What needs to be done?",
"todoLine1": "Clean up the room",
"todoLine2": "Check email"
}