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,760 points
873 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 31, 2018 in Selenium by king_kenny
• 3,710 points
2,335 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, 2019 in Selenium by Anvi
• 14,150 points
1,636 views
0 votes
1 answer
0 votes
2 answers

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,500 points
13,674 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,143 views
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,910 points
7,221 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,874 views
0 votes
2 answers

Is there any way to get the text of a web element using Selenium Webdriver?

use gettext() in java : string lableText = ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
8,485 views
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, 2019 in Selenium by Yogesh
6,451 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP