javascript - how to call the function in the specs - Protractor -


i write script under module:

   var enter_search = function () {    this.clicksearch = function (value) {      element(by.id('searchbutton')).click();  };      this.waitelementfound = function (value) {      var ec = protractor.expectedconditions;      browser.wait(ec.presenceof(value), 35000);  };    };  module.exports = new enter_search();

and call function on spec, wrote this:

var search =  require('enter_search');  var loadtxt = element (by.id('text'));    it('waits element', function(){    search.waitelementfound(loadtxt);    search.clicksearch();  });

when execute test, gives me error undefined function. not sure went wrong. thanks

to use functions 1 file in another, should export function , require in other file. here's example -

file test.js

var search =  require('./helper.js'); var loadtxt = element(by.id('text'));  it('waits element', function(){     search.waitelementfound(loadtxt); }); 

file helper.js

var waitelementfound = function (value) {     var ec = protractor.expectedconditions;     browser.wait(ec.visibilityof(value), 35000); };  module.exports = new waitelementfound(); //export function 

hope helps.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -