javascript - Protractor-cucumberjs: browser.get() does not work -


when run cucumberjs protractor, error message, can me raise reason:

c:\users\dave.le\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108 var template = new error(this.message); ^ nosuchelementerror: unable locate element: {"method":"id","selector":"log"} documentation on error, please visit: http://seleniumhq.org/exceptions/no_such_element.html build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16' system info: host: 'davele-pc', ip: '192.168.1.16', os.name: 'windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_75' driver info: driver.version: unknown @ new bot.error (c:\users\dave.le\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108:18) @ object.bot.response.checkresponse (c:\users\dave.le\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:109:9) @ c:\users\dave.le\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:379:20 @ [object object].promise.controlflow.runinframe_ (c:/users/dave.le/appdata/roaming/npm/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20) @ [object object].goog.defineclass.notify (c:/users/dave.le/appdata/roaming/npm/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25) @ [object object].promise.promise.notify_ (c:/users/dave.le/appdata/roaming/npm/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12) @ array.foreach (native) @ [object object].promise.promise.notifyall_ (c:/users/dave.le/appdata/roaming/npm/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15) @ goog.async.run.processworkqueue (c:\users\dave.le\appdata\roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:130:15) @ process._tickdomaincallback (node.js:409:9) [launcher] process exited error code 1

----------------------loginpage.js-------------------

'use strict';  ( function () {  var navigate = function () {     browser.get( 'http://store.demoqa.com/products-page/your-account/' ); };  var login = function ( username, password ) {     this.username.sendkeys( username );     this.password.sendkeys( password );     this.loginbutton.click(); };  var loginpage = function () {     this.username     = dv.findelement( by.id( 'log' ) );     this.password     = dv.findelement( by.id( 'pwd' ) );     this.loginbutton  = dv.findelement( by.id( 'login' ) ); };  loginpage.prototype.navigate = navigate; loginpage.prototype.login    = login;  module.exports = loginpage;  } )(); 

------------------------spec.js---------------------

'use strict';  var loginpage      = require( '../login/loginpage.js' );  var homepage       = require( '../../features/homepage/homepage.js' );  var chai           = require( '../../chai' );  var chaiaspromised = require( '../../chai-as-promised' );  chai.use( chaiaspromised );  var expect = chai.expect;  module.exports = function () {  var loginpage; var homepage;  this.before( function ( callback ) {     loginpage = new loginpage();     homepage  = new homepage();     isangularsite(false);     loginpage.navigate();     callback();  } );  this.after( function ( callback ) {     //logout     callback(); } );  // first scenario //this.when('i in login page')  this.given(/^i login using valid creadentials$/, function ( callback ) {      loginpage.login( 'username', 'password' ); //valid creadential     callback(); } );  this.then(/^i should logged in$/, function ( callback ) {     expect(homepage.homeindicator).toequal('http://someurl.com/#home');     callback(); } );  }; 

----------------------config.js------------------

'use strict';  var config = {  seleniumaddress : 'http://localhost:4444/wd/hub', specs           : [ 'features/login/login.feature' ], baseurl         : 'http://store.demoqa.com/', capabilities    : { browsername : 'firefox' },  onprepare   : function () { var width  = 1024; var height = 600;  global.dv = browser.driver;  dv.manage().window().setsize( width, height );  // tell protractor not wait angular global.isangularsite = function(flag) {     browser.ignoresynchronization = !flag; }; },  framework : 'cucumber',  cucumberopts : { // define step definitions in file require : 'features/login/spec.js', //format  : 'pretty' }  };  exports.config = config; 

---------------login.feature-----------------

feature: login  user, should able have login creadentials can login    system  scenario: valid login creadentials  given login using valid creadentials  should logged in 

the reason forgot add bracket in set function in loginpage.js. replace

loginpage.prototype.navigate = navigate; loginpage.prototype.login    = login; 

by:

loginpage.prototype.navigate = navigate(); loginpage.prototype.login    = login(); 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -