I want to fail the testcase for the following condition. I am able to run it, but the testcase is not failing right away. The test goes on to the next step. Please help with scenario so I can fail the testcase and the rest of the code does not run. TIA.
WebDriver driver = DriverFactory.getWebDriver()
String ErrorMsg = driver.findElement(By.className(‘text-danger’)).text
if (ErrorMsg == “”) {
//testcase passed
}
else {
//testcase failed
FailureHandling.STOP_ON_FAILURE
}
Use this:
When developing lengthy Test Cases, it’s useful to be able to stop execution to examine the state of the browser. True, you could use the debugger, but many times it’s overkill and I don’t actually want to examine the test code.
For me, this little method does exactly what I want – it kills the test at the exact point I need and allows me to do something in the browser:
import com.kms.katalon.core.exception.StepErrorException as StepErrorException
...
public class mytools {
static void FO…
https://docs.katalon.com/katalon-studio/docs/force-stop-execution.html
Thanks @Timo_Kuisma1 and @Russ_Thomas
Used StepErrorException and it worked!