trying to test without ptor.sleep()
Greetings, My test below doesn't wait to exit unless I put ptor.sleep(1000), right after the click. Anything obvious I'm doing wrong and not understanding the control flow?
thanks!!
it('Clicks Vulnerability "Critical" bar, lands on the same patch list of vulnerable patches. Tooltip must match.', function() {
ptor.ignoreSynchronization = false;
var valAnswer, valToolTip = 0;
//the bar "Critical" is the first of five bars.
var barCritical = element.all(By.css('#vulnOverviewChart .discreteBar')).get(0);
browser.actions().mouseMove(barCritical).perform();
var toolTipCount = element(By.css(".nvtooltip.xy-tooltip")).getAttribute();
toolTipCount.getText().then(function(sevString) {
valToolTip = parseInt(sevString);
expect(element(By.css(".nvtooltip.xy-tooltip")).isPresent()).toBe(true);
});
// click on the bar, get the result and test it.
barCritical.click().then(function(valAnswer) {
ptor.sleep(1000); // need this, because i think the page gets reloaded to new landing page, after click.
var AnswerCountElement = element(by.binding('patchCount | number')).getAttribute();
AnswerCountElement.getText().then(function(sevStringAnswer) {
valAnswer = parseInt(sevStringAnswer);
expect(valAnswer).toBe(valToolTip);
});
});
}); // to do: test the remaining bars.
Use "browser.wait()" rather using "ptor.sleep" to make browser wait until a particular element is present on next page.
brower.wait (function(){ browser.isElementPresent(by.binding('patchCount | number')).then(function(result){ if(result){ var AnswerCountElement = element(by.binding('patchCount | number')).getAttribute(); AnswerCountElement.getText().then(function(sevStringAnswer) { valAnswer = parseInt(sevStringAnswer); expect(valAnswer).toBe(valToolTip); }); } }); },10000);
Thanks salljusuresh,
on the right track, now, I get a Timeout.
Message: Error: Wait timed out after 10513ms
I think I've removed calls to polling with $timeout in Angular. My thoughts are the the page gets reloaded or refreshed after the click, thus losing the reference to the current promise? thanks, jay
Please read the contributing guidelines; these types of questions are ill-suited for GitHub. Thanks!