angularjs - browser.wait() does not work when there is no spinner in ProtratorJs Test -
i facing weird behaviour of browser.wait()
. in test website sometime spinner appear , sometime not appear handle situation using browser.wait()
. when there no spinner appears in page in condition code not working , throwing exception. can please me resolve issue. how can make sure if there no spinner execution continue if there spinner wait spinner finish , move next step in test.
below code:
this.waitforspinnerfinished = () => { browser.wait(function() { return element(by.css('.spinner')).isdisplayed().then(function(result) { return !result; }) }, 30000) }}
bug report
node version: v6.10.0 protractor version: 4.0.9 angular version: 1.x browser(s): chrome operating system , version windows 10
your protractor configuration file
require('babel-register'); exports.config = { directconnect: true, // chrome driver location if different installed webdriver-manager update, when directconnect: true chromedriver: './4_utilsobjects/chromedriver_2.29.exe', allscriptstimeout: 180000, framework: 'jasmine', suites: { tests: ['1_testlaunchers/*.js'], visual: ['visualregression/*.js'], }, rootelement: '[ng-app="preapp"]', capabilities: { 'browsername': 'chrome', 'chromeoptions': { // needed disable saving passwords in account creation tests 'prefs': { 'credentials_enable_service': false, 'profile': { 'password_manager_enabled': false } } }, }, jasminenodeopts: { silent: true, defaulttimeoutinterval: 180000, // needed jasmine-spec-reporter print: function () { } }, onprepare: () => { // here we're adding real time jasmine reporter display test steps // see https://github.com/bcaudan/jasmine-spec-reporter var specreporter = require('jasmine-spec-reporter'); // add jasmine spec reporter jasmine.getenv().addreporter(new specreporter({ displaystacktrace: 'none', displaysuccessfulspec: true, displayfailedspec: true, displayspecduration: true, displaysuitenumber: true, displaypendingsummary: false, displaypendingspec: false })) // adding jasmine junit reporter var jasminereporters = require('jasmine-reporters'); jasmine.getenv().addreporter(new jasminereporters.junitxmlreporter({ consolidateall: true, savepath: 'reports/junitreporter', fileprefix: 'testresults' })) // reporter teamcity, enabled in ci if (process.env.teamcity_version) { jasmine.getenv().addreporter(new jasminereporters.teamcityreporter()); } // disable animations e2e tests run faster var disablenganimate = function () { angular.module('disablenganimate', []).run(['$animate',function ($animate) { $animate.enabled(false); }]); } browser.addmockmodule('disablenganimate', disablenganimate); // reporter taking screenshots when failed assertion spotted, comment out speed test run var jasmine2htmlreporter = require('protractor-jasmine2-html-reporter'); jasmine.getenv().addreporter(new jasmine2htmlreporter({ savepath: 'reports/screenshotreporter/', takescreenshotsonlyonfailures: true, })) } }
a relevant example test
this.startsignup = () => { element(by.css('#protractorjs')).click(); this.waitforspinnerfinished(); }
output running test
- failed: no element found using locator: by(css selector, '.spinner')
it's been while since wrote in protractor don't have place test work if change return in waitforspinnerfinished
to:
return result === false;
Comments
Post a Comment