javascript - Protractor writing a cleaner test cases without using browser.sleep -


im new protractor , jasmine , use lot of browser.sleep make test cases work

it('procedure tab-', function() {          element(by.linktext('medical history')).click();         browser.sleep(500)         element(by.linktext('personal history')).click();         browser.sleep(200)         element(by.linktext('procedure')).click();         browser.sleep(500)         element(by.css('[data-ng-show="ptab.index  === 1"] > [profile="profile"] > #medicalhistory > .card > [header="header"] > .card-header-bg > .title-header > .row > [ui-sref=".procedure.new"] > [data-ng-hide="important"]')).click();         browser.sleep(500)         $('label[for="dis4appendicitis"]').click();         browser.sleep(2000)     }) 

what more efficient way write test case without using browser.sleep........i have been using sleeps because of slower internet connectivity etc....

any appreciated

an efficient way perform test using implicit , explicit waits. implicit wait can added in conf.js file protractor takes consideration @ beginning of test execution. here's example -

browser.manage().timeouts().implicitlywait(10000); //wait 10 seconds before failing particular actions/operations 

and explicit waits can achieved using wait() function coupled expectedconditions.

this efficiently replaces browser.sleep() method continuously checking expected condition specified.

here's how use -

var ec = protractor.expectedconditions; var elem = element(by.css(locator)); browser.wait(ec.visibilityof(elem), 10000); //wait 10 seconds before failing step 

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 -