If test failure then

Hello. Help me please.
Is there any way to condition test execution?
For example, I have a test which should to fail.
How to set the condition that in case of error write a text in a variable?


test case cannot fail. Test step (or more steps) can fail. Ultimately, it means that also a whole test case failed.

If-else statement can handle such a situation as you described, but I need more info to provide more specific help.

Oh yes, sorry.
One step fails.

So, I have a test that takes over URLs from a file (source.xlsx). After which the test opens the browser to this address and takes the title of the page for write it down in another file (destination.xlsx).

Sun cases when the file address was misspelled and because of this shows error.

I would like in case the address is wrong to write to the file (destination.xlsx) - ‘xxxxxx’

Ok, I checked it out and it seems that different browsers handle non-existing pages differently. Chrome puts a webpage in page title, FF and IE web drivers throw an exception. You have to find out how to handle those situations.

But generally:

// read all URLs and put it into a list 
List allUrls = Arrays.asList("www.katalon.com", "www.katal0n.com")

for(String url in allUrls) {
	String pageTitle = DriverFactory.getWebDriver().getTitle()
	if(// tbd - decide if URI is correct //) {
		// write 'xxxx' into a file
	} else {
		// write _url_ variable into a file
1 Like

Thank you very much.