Using object composition instead of class inheritance for page objects
This commit is contained in:
parent
f106cd2850
commit
c3e9781dc4
6 changed files with 60 additions and 80 deletions
|
@ -1,30 +1,27 @@
|
|||
'use strict';
|
||||
|
||||
const Page = require('./page');
|
||||
|
||||
class Login extends Page {
|
||||
enterUsername(value) {
|
||||
// this.element('usernameInput').clear();
|
||||
return this.element('usernameInput').sendKeys(value);
|
||||
}
|
||||
enterPassword(value) {
|
||||
return this.element('passwordInput').sendKeys(value);
|
||||
}
|
||||
}
|
||||
const page = require('./page');
|
||||
|
||||
module.exports = driver => ({
|
||||
|
||||
login: new Login(driver, {
|
||||
login: Object.assign(page(driver), {
|
||||
url: '/users/login',
|
||||
elementToWaitFor: 'submitButton',
|
||||
elements: {
|
||||
usernameInput: 'form[action="/users/login"] input[name="username"]',
|
||||
passwordInput: 'form[action="/users/login"] input[name="password"]',
|
||||
submitButton: 'form[action="/users/login"] [type=submit]'
|
||||
},
|
||||
enterUsername(value) {
|
||||
// this.element('usernameInput').clear();
|
||||
return this.element('usernameInput').sendKeys(value);
|
||||
},
|
||||
enterPassword(value) {
|
||||
return this.element('passwordInput').sendKeys(value);
|
||||
}
|
||||
}),
|
||||
|
||||
account: new Page(driver, {
|
||||
account: Object.assign(page(driver), {
|
||||
url: '/users/account',
|
||||
elementToWaitFor: 'emailInput',
|
||||
elements: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue