For debugging my protractor test cases, I have developed helper methods. One of the key functions is waiting for an element to be clickable. To ensure that Protractor has enough time to find and enable the element, I am implementing a loop. However, in case the element is not located due to a typo or other issues in the script, I want the test run to immediately STOP and mark it as a FAILURE.
async WaitToBeClickable(element){
try{
for(var i = 0; i <= 3000; i++){
var wait = await browser.wait(this.EC.elementToBeClickable(element), i);
if(wait == true){
break;
}else{
//this is where I want to fail
}
}
}catch(err){
//this is where I want to fail
await console.log(`WAIT TO BE CLICKABLE FAILED:\n${element.parentElementArrayFinder.locator_.value}\n\nError:\n${err}\n`);
}
};
This feature aids greatly in debugging my scripts while working on VSC. However, I am struggling to figure out how to make the test FAIL and close the browser upon the first failure. The options like protractor-fail-fast and protractor-bail-fast seem to cater to Jasmine test cases rather than individual functions. Any assistance would be highly appreciated as Protractor is making me a bit frustrated at the moment!