Is there a method by which we can control the running of a test case?

0 votes
Is there a way by which we can control the running of a test case to run only after running few particular test case in selenium?

I just know one method of setting priority but that again won't come handy for a class having multiple test functions.

Can someone help me in this?
Dec 27, 2018 in Selenium by Sradha
• 1,720 points
50 views
You can use dependency.

1 answer to this question.

0 votes

Hey @sradha, yes there is a way by which you can do exactly what you want. This is known as dependency in testNG. 

Dependency is when you have a function which needs to run after a particular function/s completes testing. By this you can do exactly same as you require.

All you need to do is you need to make a test function dependent.

  @Test (dependsOnMethods= "h2" )
  public void h1() 
  {
  System.out.println("test case 1");
  }
  @Test
  public void h2() 
  {
  System.out.println("test case 2");
  }
  @Test
  public void h3() 
  {
  System.out.println("test case 3");
  }
  @Test
  public void h4() 
  {
  System.out.println("test case 4");
  }

This way h1 will run only when h2 is completed.

Hope this helps.

answered Dec 27, 2018 by Nabarupa

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

Can we control the test execution speed in WebDriver (using Ruby)

The methods controlling execution speed in WebDriver ...READ MORE

answered May 30, 2018 in Selenium by king_kenny
• 3,650 points
177 views
0 votes
1 answer

Is it possible to exclude a particular test method from a test case execution?

Hello Tarang, you can exclude a particular ...READ MORE

answered Jun 19 in Selenium by Anvi
• 12,840 points
24 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
555 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
890 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
553 views
0 votes
1 answer
0 votes
1 answer

What is the use of deSelectAll() method in Selenium Webdriver?

Hello Inderjeet, deselectAll() method is useful to ...READ MORE

answered May 31 in Selenium by Yogesh
188 views