I am attempting to use an 'If' condition to determine the presence status of an element, but I'm having trouble getting a simple 'true' or 'false' result. Instead, I get an error message like this when the element is not found:
- Failed: No element found using locator: By(css selector, .alert-message.ng-binding.alert.alert-success)
Here is the code I've implemented:
describe("test 1", function () {
it("testing", function () {
var userCreationSuccessConfirmationMsg = element(by.className('alert-message ng-binding alert alert-success'));
var userCreationFailureConfirmationMsg = element(by.className('alert-message ng-binding alert alert-danger'));
browser.driver.get(testData.UBETURL);
login.loginToUbet('sysadmin', 'password');
console.log('Somesh');
element(by.linkText('Configuration')).click();
element(by.linkText('Create New User')).click();
element.all(by.id('saveUser')).first().click();
console.log(expect(userCreationSuccessConfirmationMsg.isDisplayed()));
userCreationSuccessConfirmationMsg.isDisplayed().then(function (status) {
if (status) {
console.log(status);
} else {
console.lgo(status);
}
});
});
});
Can anyone provide guidance on how to obtain the availability status of an element in Boolean using 'if' conditions?