I am using protractor to Automate the mobile app. I need to verify if the toggle button(Toggle button Image attached) is checked or not, or enabled or disabled. If not selected, select and do some operations, but everytime it says, selected even if not selected and disabled.
Here is my Code attached:::::::::::
var checkNoti = AppNoti.isSelected();
if (checkNoti)
{
checkNoti.then( function() {
console.log('The App notification is enabled Already!!');
});
}
else {
AppNoti.click().then( function() {
console.log('The App notification is Enabled');
});
};
Kindly advise...All the time, it says, toggle checkbox button is enabled, even if its disabled.
checkNoti
value in the if (checkNoti)
check would always evaluate as true since it is not a boolean value - it is a promise. You need to resolve it:
AppNoti.isSelected().then(function (selected) {
if (!selected) {
AppNoti.click().then(function() {
console.log('The App notification is Enabled');
});
}
});