Can anyone explain the annotations available in TestNG?

0 votes
Jun 10, 2019 in Selenium by Ishika
107 views

1 answer to this question.

0 votes

Hi Ishika, following annotations are available in TestNG:

  1. @BeforeGroups: This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked.

  2. @AfterGroups: This method is guaranteed to run shortly after the last test method that belongs to any of these groups is invoked.

  3. @BeforeMethod: The annotated method will be run before each test method.

  4. @AfterMethod: The annotated method will be run after each test method.

  5. @BeforeSuite: Run only once before all tests in this suite have run.

  6. @AfterSuite: Run only once after all tests in this suite have run.

  7. @BeforeClass: Run only once before the first test method in the current class is invoked.

  8. @AfterClass: Run only once after all the test methods in the current class have run.

  9. @BeforeTest: Run before any test method belonging to the classes inside the <test> tag is run.

  10. @AfterTest: Run after all the test methods belonging to the classes inside the <test> tag have run.

  11. @Listeners: Defines listeners on a test class.

  12. @Parameters: Describes how to pass parameters to a @Test method.

  13. @Test: Marks a class or a method as a part of the test.

  14. @DataProvider: Marks a method as supplying data for a test method. The annotated method must return an Object[ ][ ], where each Object[ ] can be assigned the parameter list of the test method. The @Test method that wants to receive data from this DataProvider needs to use a dataProvider name equals to the name of this annotation.

  15. @Factory: Marks a method as a factory that returns objects that will be used by TestNG as Test classes. The method must return Object[ ].

answered Jun 10, 2019 by Abha
• 27,910 points

Related Questions In Selenium

+1 vote
1 answer

How can I automate the process of adding iPhone to cart in Flipkart using Selenium(java),Page Object Model and TestNG? Also validate if product is added and available in cart?

Hey check this https://www.edureka.co/community/47160/automate-purchase-adding-book-cart-flipkart-using-selenium? It deals with a similar ...READ MORE

answered Jan 13 in Selenium by Karan
• 10,310 points
2,152 views
0 votes
1 answer

Can anyone explain how an AJAX call can be handled in Selenium webdriver?

Hello Megha, to demonstrate how AJAX calls are ...READ MORE

answered May 8, 2019 in Selenium by Pratibha
• 3,690 points
283 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,510 points
2,850 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,870 points
2,212 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,870 points
2,325 views
+1 vote
2 answers