I have been using/learning protractor for more than a month now.
I know that protractor documentation says,it waits for angular calls to complete (http://www.protractortest.org/#/) , it will make sure all steps are executed synchronously etc..
But I don't find it that way. Or at least, I don't find it that way in my scripts Many a time protractor runs ahead, for example if I click on a link, get the current url and then verify the url.
Most of the time, URL value will be stale, i.e it was not executed after clicking on link. Below is my code sample from page object and corresponding test.
Please suggest how to make sure, all test steps are executed in serial order.
Page Object
this.getSPageLink(){
return element(by.xpath("//a[@title='S']"));
};
this.getLPageLink(){
return element(by.xpath("//a[@title='L']"));
};
this.goToSPage = function() {
(this.getSPageLink()).click();
*//ERROR here, sometimes second click (below) doesn't wait for first
click to complete, and complains that link for 2 click (below) is
not found*
(this.getSLPageLink()).click();
return browser.currentURL();
*//ERROR HERE url line (e) is sometimes executed before*
}
Test Class
it('::test SL page', function() {
pageObject.goToSpage();
var currentURL=browser.getCurrentURL();
expect(currentURL).toContain("SLink");
*//ERROR HERE value in this variable "currentURL" is most of the
times Stale*
});
it('::test SL2 page', function() {
pageObject.goToLpage();
var currentURL=browser.getCurrentURL();
expect(currentURL).toContain("Link");
console.log("this line is always executed first"));
//ERROR here , this print line is always executed first
});