Throw new SkipException not working | Selenium Forum
P
Pinki Daga Posted on 20/10/2019

I want to skip following testcase - so i used 'throw new SkipException'

But it is throwing error in next line - system asking me to comment out all the subsequent lines.

 

How to skip test cases then?

I used (enabled=false) but why above not working?

public void sellStock() throws InterruptedException, ParseException {

//throw new SkipException("oooooo");

waitForPageLoad();


A
Ashish Thakur Replied on 21/10/2019

The code should work. Please share the screenshot of the issue.


P
Pinki Daga Replied on 23/10/2019

Responsive image


P
Pinki Daga Replied on 23/10/2019

I was using TestNG framework above


A
Ashish Thakur Replied on 24/10/2019

On what condition you want to throw skip exception?

Line number 146 will stop the execution immediately.

 

No matter what code is written after line number 146, that will not get executed.

Make sure that this is surrounded under a if statement.


P
Pinki Daga Replied on 25/10/2019

Make sure that this is surrounded under a if statement.==> Can you please let me know what if statement?

Also if you see the subsequent lines, they are throwing errors - my understanding is mentioned this throw statement means i am skiping the execution and this will be first line under test case.


A
Ashish Thakur Replied on 25/10/2019

If(Condition to check){

throw new skipException("Failure Message");

}

 Surround the code with the code above.