Protractor is failing when trying to click a button. Initially the button will be in disabled status (after sometime it will be enabled) and protractor thinks that the button is ready and clicking on the button and failing.
So i want the protractor script to wait till the button is enabled. I have tried below, but it didn't work. Can someone please post the complete code to wait for the element to be enabled?
expect(browser.wait(function(){return browser.driver.isElementPresent(by.id('paynow-info-btn'))}, 10000));
wait(function () { return elem. isDisplayed(); });
The reason to add implicitlyWait() there is because implicit wait is the default time that protractor waits before passing or throwing an error for an action.
getAttribute('disabled')). toEqual('disabled'); to accurately verify if something is enabled/disabled.
ExpectedConditions View code Represents a library of canned expected conditions that are useful for protractor, especially when dealing with non-angular apps. Each condition returns a function that evaluates to a promise. You may mix multiple conditions using and , or , and/or not .
There is a very much suitable Expected Condition - elementToBeClickable
- it would wait for an element to be both visible and enabled:
var elm = element(by.id('paynow-info-btn'));
var EC = protractor.ExpectedConditions;
browser.wait(EC.elementToBeClickable(elm), 5000);
elm.click();
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