How to disable Selenium Testcases using TestNG Feature


Welcome to Selenium Tutorial, Today we are going to discuss very silent feature of TestNG which allow us to enable or disable our test case based on our requirement.

Why to Disable Selenium Test cases?

Before moving forward you should have Eclipse TestNG setup ready if still not configured then please do Selenium Eclipse setup now.

Once our test suite size will increase day by day then chances are high that you don’t want to execute some test cases.

Ok so let’s consider a scenario that you have written 10 testcases but now you want to execute only 5 testcase because other 5 are working correctly


How to Disable Selenium Test cases?

In TestNG we can achieve this by simply adding enable attribute and can set value to true/false.


If test case enable as false them while running test cases TestRunner simply will ignore this testcase and will only run testcase whose enable is set to true.

Note- By default @Test is set to enable

Scenario – I have 3 test case but I want to execute only 2 test case.

Precondition- TestNG should be installed

Program for – Disable Selenium Test cases


Lets check the output

Disable Selenium Test

Disable Selenium Test

Above program is executing only 2 testcases which has been passed. One test case in not executed  because that test case we have enable =false.

Hope this post helpful for you. Keep sharing with your friends. Comment below if you finding any issue while working with Selenium or TestNG.

Have a nice day 🙂

Like Facebook Page for more updates-Learn-Automation facebook page

Join Selenium Group for discussion and queries- Learn-Automation group


  1. sam
  2. Mukesh