Trying my hand at constructing a page object for login testing with WebdriverIO.
Encountering the error
ERROR: Class extends value #<Page> is not a function or null
on line 3 of login.page.js
.
No clue what mistake I'm making... Is there a wrong path or filename somewhere?
/tests/specs/login.specs.js
var expect = require('chai').expect
var LoginPage = require('../pageobjects/login.page')
describe('login form', function () {
it('should deny access with wrong creds', function () {
LoginPage.open()
LoginPage.username.setValue('foo')
LoginPage.password.setValue('bar')
LoginPage.submit()
expect(LoginPage.flash.getText()).to.contain('Your username is invalid!')
})
})
/tests/pageobjects/page
'use strict'
class Page {
constructor() {
this.title = 'My Page'
}
open(path) {
browser.url('/' + path)
}
}
module.exports = new Page()
/tests/pageobjects/login.page.js
'use strict'
var Page = require('./page')
class LoginPage extends Page {
get username () { return browser.element('#username') }
get password () { return browser.element('#password') }
get form () { return browser.element('#login') }
get flash () { return browser.element('#flash') }
open () {
super.open('login')
}
submit () {
this.form.submitForm()
}
}
module.exports = new LoginPage()