javascript - Protractor page object issues -


i seem stuck in construction of page objects. read lot of docs page objects , know contain 2 things:

  • elements present on page
  • functions interact page

when check example files see elements defined in beginning of each page object. in test, pageobject imported via require. problem see there objects aren't yet present when require happens. there way solve without having require when page loaded?

thanks inadvance. regards

there new protractor style guide coming (currently in review), should clear things lot, page object creation , requiring part. here current draft:

regarding question, first of all, page objects need defined functions, declaring page object elements in constructor:

var questionpage = function() {   this.question = element(by.model('question.text'));   this.answer = element(by.binding('answer'));   this.button = element(by.classname('question-button'));    this.ask = function(question) {     this.question.sendkeys(question);     this.button.click();   }; };  module.exports = questionpage; 

then, require page object at top of test suite:

var questionpage = require('./question-page');  describe('my test', function() {     ... }); 

instantiate page object inside test suite:

describe('my test', function() {   var questionpage = new questionpage();    // specs }); 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -