In a test spec, I need to click a button on a web page, and wait for the new page completely loaded.
emailEl.sendKeys('jack'); passwordEl.sendKeys('123pwd'); btnLoginEl.click(); // ...Here need to wait for page complete... How? ptor.waitForAngular(); expect(ptor.getCurrentUrl()).toEqual(url + 'abc#/efg');
pageLoadTimeout() method in protractor waits for an page to load within given time limit when we use get() or navigate().to() method to load a webpage.
sleep(1000) in order to wait for an element with Protractor. Instead use ExpectedConditions in order to with Protractor. browser. wait(EC.
This means that Protractor does not know when your page is fully loaded, and you may need to add a wait statement to make sure your tests avoid race conditions. If your page uses $timeout for polling Protractor will not be able to tell when your page is ready. Consider using $interval instead of $timeout .
Double Click Mouse Actions In Selenium Protractor Similar to the click method the doubleClick () method simulates a double click of the mouse. Generally, when an element is double clicked it either activates the particular element or lifts that object from a certain point.
Depending on what you want to do, you can try:
browser.waitForAngular();
or
btnLoginEl.click().then(function() { // do some stuff });
to solve the promise. It would be better if you can do that in the beforeEach
.
NB: I noticed that the expect() waits for the promise inside (i.e. getCurrentUrl) to be solved before comparing.
I just had a look at the source - Protractor is waiting for Angular only in a few cases (like when element.all
is invoked, or setting / getting location).
So Protractor won't wait for Angular to stabilise after every command.
Also, it looks like sometimes in my tests I had a race between Angular digest cycle and click event, so sometimes I have to do:
elm.click(); browser.driver.sleep(1000); browser.waitForAngular();
using sleep to wait for execution to enter AngularJS context (triggered by click
event).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With