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,710 points
40 views
You can use dependency.

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,590 points
51 views
0 votes
1 answer
0 votes
1 answer

Selenium Alternatives: Is there a tool like Selenium for testing web pages but which does not involve coding.

I'm guessing you've tried Selenium IDE already. ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,590 points
42 views
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,030 points
51 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
409 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
40 views
+1 vote
2 answers

How to get the title of a webpage using Selenium Java?

Essentially, driver.getTitle(); function can be used to ...READ MORE

answered Dec 17, 2018 in Selenium by Vardhan
• 10,530 points
66 views
+1 vote
1 answer

Can someone explain the meaning of WebDriver wd = new ChromeDriver();?

WebDriver webdriver = new ChromeDriver(); The following simply ...READ MORE

answered Dec 14, 2018 in Selenium by Aniket
59 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.