elementX.isPresent()
.then(() => {
elementX.all(by.cssContainingText('option', text)).click()
.catch(error => {
throw {message: "Unable to select text in dropdown box"}
})
})
.catch (error => {
throw {message : "element is not present"}
})
I am facing an issue where I want to throw 2 different error messages, one if the element is missing and another if the given text is missing in the dropdown.
Currently, if the element is missing, the error is thrown correctly. However, if the element is present but the given text is missing, it still throws the "element is not present" error message. How can I modify the code to throw the correct error message?
I tried modifying the code as follows:
elementX.isPresent()
.then(
_ => elementX.all(by.cssContainingText('option', text)).click()
.then(() => {
console.log("hello")
})
.catch(_ => { throw {message: "Unable to select text in dropdown box"} }),
_ => { throw {message : "element is not present"} }
)
I followed a suggestion to change the code above, but it did not work as expected and only returned the last catch message.