When users click the submission button, it becomes disabled until the operation is complete and they are redirected to the /dashboard
page.
We want to ensure this 'disabled while pending' feature is tested in our Protractor end-to-end tests:
it('should disable button after submission', function(){
page.usernameTextBox.sendKeys(username);
page.passwordTextBox.sendKeys('password1');
page.signInButton.click();
expect(page.signInButton.getAttribute('disabled')).toContain('true');
expect(browser.getCurrentUrl()).toContain('/dashboard');
});
The assertion on the disabled
attribute fails because the next page has already loaded. This is due to Protractor waiting for the operation to be completed before running the assertion - not a race condition. Protractor synchronizes the process so the assertion waits for the operation to finish before executing.
How can we effectively test the above behavior?