I need to fail test if element is not present using protractor. Here, I have implemented code. When expect condition out of if condition I expected it will fail. Unfortunately, test case is passing. Can anyone suggest if anything that i missed.
crossAttribute.isPresent().then(function (deleteAttribute) {
if(deleteAttribute){
crossAttribute.click();
}else{
console.log('Cross is not present to delete attribute')
}
expect(crossAttribute).toBeTruthy;
});
this will work easily
let attributeIsPresent = await crossAttribute.isPresent()
if (attributeIsPresent) {
await crossAttribute.click();
} else {
expect(false).toBe(true)
}
your code didn't work because you used wrong variable crossAttribute
instead of deleteAttribute
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.