javascript - Too many browser.wait calls in protractorjs -
my test steps test logout flow are,
1) click logout button
2) wait url change login.html
3) wait login page text fields loaded.
code looks like,
//wait logout menu/button browser.wait(function(){ return element(by.buttontext('log out')).ispresent() }) element(by.buttontext('log out')).click() //wait url change login.html browser.wait(function(){ return browser.getcurrenturl().then(function(url){ return url.indexof("login") != -1 }) }) //wait login page text boxes browser.wait(function(){ return element(by.css('[type=text]')).ispresent() })
this makes code lengthy since, wrapping each action inside browser.wait
call. there way can avoid browser.wait
. tried adding,
browser.manage().timeouts().implicitlywait(5000)
but then, no element found using locator: by.buttontext("log out")
error.
protractor has inbuilt expectedconditions
checks, don't have write custom function time. here's how wait element visible -
var ec = protractor.expectedconditions; browser.wait(ec.presenceof(element(by.buttontext('log out'))), 10000); //checks if element present in dom browser.wait(ec.visibilityof(element(by.buttontext('log out'))), 10000); //checks if element present in dom , visible user on page
you can create custom function shown in answer. hope helps.
Comments
Post a Comment