I am trying to write a simple test using the page object template - based on docs / page-objects '.
I created a file that describes the page object, and another, using this page object to test the page.
//page object var LoginPage = function() { this.userInput = browser.driver.findElement(by.id('username')); this.pwdInput = browser.driver.findElement(by.id('password')); this.btnEnter = browser.driver.findElement(by.id('btnLogin')); this.get = function(){ browser.get('http://example.com'); }; this.setUser = function (user){ this.userInput.sendKeys(user); }; this.setPasswd = function (password) { this.pwdInput.sendKeys(password); }; this.clickBtnEnter = function (){ btnEnter.click(); };};
Specification File:
var loginPage = require('./LoginPage.js'); describe('myApp', function() { it('should save contract config', function (){ loginPage.get(); loginPage.setUser('userid'); loginPage.setPasswd('passwd'); loginPage.clickBtnEnter(); }); });
When starting this test, the following error is displayed: TypeError: Object # does not have a 'get' method - in this line: loginPage.get () ;.
When I looked for this problem, I found various approaches to using page objects in Protractor, for example Astrolable . Now I'm not sure about the proper use of page objects.
Do you have any ideas on how I can fix this test?
Thanks guys.
source share