{"id":91315,"date":"2019-04-30T10:00:23","date_gmt":"2019-04-30T07:00:23","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=91315"},"modified":"2019-04-25T09:36:50","modified_gmt":"2019-04-25T06:36:50","slug":"complete-guid-testng-annotations-selenium-webdriver","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html","title":{"rendered":"Complete Guide On TestNG Annotations For Selenium WebDriver"},"content":{"rendered":"<p><b>TestNG is a testing framework created by C\u00e9dric Beust<\/b> and helps to cater a lot of our testing needs. It is widely used in Selenium. Wondering on what NG stands for? Well, it refers to <b>\u2018Next Generation\u2019<\/b>. TestNG is similar to Junit but is more powerful to it when it comes to controlling the execution flow of your program. As the nature of framework, we tend to make our tests more structured and provides better validation points through the use of TestNG.<\/p>\n<p>Some of the noteworthy features of TestNG are:<\/p>\n<ul class=\"wp-block-list\">\n<li>Powerful and wide variety of annotations to support your test cases.<\/li>\n<li>Helps to perform parallel testing, dependent method testing.<\/li>\n<li>Flexibility of running your tests through multiple sets of data through TestNG.xml file or via data-provider concept.<\/li>\n<li>Test cases can be grouped and prioritized as per need basis.<\/li>\n<li>Provides access to HTML reports and can be customized through various plugins.<\/li>\n<li>Test logs can be generated across tests.<\/li>\n<li>Can be easily integrated with eclipse, Maven, Jenkins etc.<\/li>\n<\/ul>\n<p>A basic process flow of a TestNG programs involves the following steps:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/blogimage-1024x420.png\" alt=\"TestNG Annotations\" class=\"wp-image-91337\" width=\"768\" height=\"315\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/blogimage-1024x420.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/blogimage-300x123.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/blogimage-768x315.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/blogimage.png 1914w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>So, before jumping onto the annotations in TestNG for Selenium, it would be better to refer the prerequisites are required to setup TestNG.<\/p>\n<p><b>Prerequisites<\/b><\/p>\n<ul class=\"wp-block-list\">\n<li>Java Development Kit<\/li>\n<li>Setup Eclipse or any other IDE.<\/li>\n<li>Install TestNG in Eclipse or any other IDE.<\/li>\n<\/ul>\n<p>Note: Annotations can be used only with Java version 1.5 or higher.<\/p>\n<p>If you are new to TestNG framework then follow our guide to run your <a href=\"https:\/\/www.lambdatest.com\/blog\/a-complete-guide-for-your-first-testng-automation-script\/\" target=\"_blank\" rel=\"noopener noreferrer\">first automation script with TestNG<\/a>.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/accounts.lambdatest.com\/register\/\"><img decoding=\"async\" width=\"431\" height=\"330\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/cta-img.png\" alt=\"TestNG Annotations\" class=\"wp-image-91338\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/cta-img.png 431w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/cta-img-300x230.png 300w\" sizes=\"(max-width: 431px) 100vw, 431px\" \/><\/a><\/figure>\n<\/div>\n<p>Run TestNG Selenium Scripts On Cloud Grid<\/p>\n<h2 class=\"wp-block-heading\">So, What Is An Annotation?<\/h2>\n<p>An annotation is a tag that provides additional information about the class or method. It is represented by<b> \u2018@\u2019 <\/b>prefix. TestNG use these annotations to help in making a robust framework. Let us have a look at these annotations of TestNG for <a href=\"https:\/\/www.lambdatest.com\/selenium-automation\" target=\"_blank\" rel=\"noopener noreferrer\">automation testing with Selenium<\/a>.<\/p>\n<h3 class=\"wp-block-heading\">@Test<\/h3>\n<p><b>The most important annotation in TestNG framework where the main business logic resides.<\/b> All functionalities to be automated are kept inside the @Test annotation method. It has various attributes based on which the method can be reformed and executed.<\/p>\n<p>Example of a code snippet below validating the url :<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@Test\n\tpublic void testCurrentUrl() throws InterruptedException\n\t{\n\t\tdriver.findElement(By.xpath(\"\/\/*[@id='app']\/header\/aside\/ul\/li[4]\/a\")).click();\n\t\n\t\tString currentUrl= driver.getCurrentUrl();\n\t\tassertEquals(current_url, \"https:\/\/automation.lambdatest.com\/timeline\/?viewType=build&amp;page=1\", \"url did not matched\");\n\t}<\/pre>\n<h3 class=\"wp-block-heading\">@BeforeTest<\/h3>\n<p><b>This annotation is run before your first @Test annotation method in your class.<\/b> You can use this annotation in TestNG for Selenium to setup your browser profile preferences, for example auto opening your browser in maximize mode, setting up your own customized profile for your browser etc.<\/p>\n<p>Below is the code snippet for BeforeTest method ensuring the browser opens in maximize mode:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@BeforeTest\n\tpublic void profileSetup()\n\t{\n\t\tdriver.manage().window().maximize();\n\t\t\n\t\t\n\t}<\/pre>\n<h3 class=\"wp-block-heading\">@AfterTest<\/h3>\n<p><b>This annotation in TestNG runs after all your test methods belonging to your class have run.<\/b> This is a useful annotation which comes handy in terms of reporting your automation results to your stakeholders. You can use this annotation to generate report of your tests and share it to your stakeholders via email.<\/p>\n<p>Example of the code snippet below:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@AfterTest\n\tpublic void reportReady()\n\t{\n\t\tSystem.out.println(\"Report is ready to be shared, with screenshots of tests\");\n\t}<\/pre>\n<h3 class=\"wp-block-heading\">@BeforeMethod<\/h3>\n<p><b>This annotation in TestNG runs before every @test annotated method.<\/b> You can use it to check out for the database connections before executing your tests or lets say different functionality been tested in your @test annotated method which requires user login in a certain class. In this case also you can put your login code in the @BeforeMethod annotation method.<\/p>\n<p>Below code snippet is an example, displaying login functionality of the LambdaTest platform:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@BeforeMethod\n\tpublic void checkLogin()\n\t{\n\t\t  driver.get(\"https:\/\/accounts.lambdatest.com\/login\");\n\t\t  driver.findElement(By.xpath(\"\/\/input[@name='email']\")).sendKeys(\"sadhvisingh24@gmail.com\");\n\t\t  driver.findElement(By.xpath(\"\/\/input[@name='password']\")).sendKeys(\"XXXXX\");\n\t\t  driver.findElement(By.xpath(\"\/\/*[@id='app']\/section\/form\/div\/div\/button\")).click();\n\t\t\n\t}<\/pre>\n<h3 class=\"wp-block-heading\">@AfterMethod<\/h3>\n<p><b>This annotation runs after every @test annotated method.<\/b> This annotation can be used to take screenshots of every test method ran against test runs .<\/p>\n<p>Below code snippet indicating screenshot taken in the @AfterTest annotation in TestNG for Selenium:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@AfterMethod\n\tpublic void screenShot() throws IOException\n\t{\n\t\tTakesScreenshot scr= ((TakesScreenshot)driver);\n        File file1= scr.getScreenshotAs(OutputType.FILE);\n        \n       FileUtils.copyFile(file1, new File(\"C:\\\\Users\\\\navyug\\\\workspace\\\\QAPractise\\\\test-output\\\\test1.PNG\"));\n       \n\t}<\/pre>\n<h3 class=\"wp-block-heading\">@BeforeClass<\/h3>\n<p><b>This annotation runs before the first test method in the current class.<\/b>This annotation can be used to setup your browser properties, initialize your driver, opening your browser with the desired URL etc.<\/p>\n<p>Below is the code snippet for BeforeClass:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@BeforeClass\n\tpublic void appSetup()\n\t{\n\t\tdriver.get(url);\n\t\t\n\t}<\/pre>\n<h3 class=\"wp-block-heading\">@AfterClass<\/h3>\n<p><b>This annotation runs after the last test method in the current class.<\/b> This annotation in TestNG can be used to perform clean up activities during your tests like closing your driver etc<\/p>\n<p>Below is the example of code snippet showing closing activities performed:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@AfterClass\n\tpublic void closeUp()\n\t{\n\t\tdriver.close();\n\t}<\/pre>\n<h3 class=\"wp-block-heading\">@BeforeSuite<\/h3>\n<p>A suite can consist of multiple classes, this annotation runs before all the tests methods of all the classes. <b>This annotation marks the entry point of execution.<\/b> @BeforeSuite annotation in TestNG can be used to perform the needed and generic functions like setting up and starting Selenium drivers or remote web drivers etc.<\/p>\n<p>Example of @BeforeSuite annotation in TestNG, code snippet showcasing setting up of driver:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@BeforeSuite\n\tpublic void setUp()\n\t{\n\tSystem.setProperty(\"webdriver.chrome.driver\", \"path to chrome driver\");\n\tdriver=new ChromeDriver();\n\t}<\/pre>\n<h3 class=\"wp-block-heading\">@AfterSuite<\/h3>\n<p><b>This annotation in TestNG runs post all the test methods of all the classes have run.<\/b> This annotation can be used to clean up the processes before completing off your tests when you have multiple classes in functioning, for example closing the drivers etc.<\/p>\n<p>Below is the code snippet for @AfterSuite annotation in TestNG for Selenium:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@AfterSuite\n\tpublic void cleanUp()\n\t{\n\t\t\n\t\tSystem.out.println(\"All close up activities completed\");\n\t}<\/pre>\n<h3 class=\"wp-block-heading\">@BeforeGroups<\/h3>\n<p>TestNG helps testers create a bunch of tests into groups through the attribute group used in the @Test annotation. For example, if you wish all similar functionalities related to user management to be clubbed together, you can mark all tests like Dashboard, profile, transactions etc. into a single group as \u2018user_management\u2019. This @BeforeGroups annotation in TestNG helps to run the defined test first before the specified group. This annotation can be used if the group focuses on a single functionality like stated in the above example. The BeforeGroup annotation can contain the login feature which is required to run before any other methods like user dashboard, user profile etc.<\/p>\n<p>Example of the Code snippet for @BeforeGroups annotation in TestNG for Selenium:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@BeforeGroups(\"urlValidation\")\n    public void setUpSecurity() {\n        System.out.println(\"url validation test starting\");\n    }<\/pre>\n<h3 class=\"wp-block-heading\">@AfterGroups<\/h3>\n<p>This annotation in TestNG runs after all the test methods of the specified group are executed.<br \/>Example of Code snippet for @AfterGroups annotation in TestNG for Selenium:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@AfterGroups(\"urlValidation\")\n    public void tearDownSecurity() {\n        System.out.println(\"url validation test finished\");\n    }\n\nThe below code displays an example of all annotations used along with TestNG report respectively:\n\nimport static org.testng.Assert.assertEquals;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.concurrent.TimeUnit;\n\nimport org.apache.commons.io.FileUtils;\nimport org.openqa.selenium.By;\nimport org.openqa.selenium.OutputType;\nimport org.openqa.selenium.TakesScreenshot;\nimport org.openqa.selenium.WebDriver;\nimport org.openqa.selenium.chrome.ChromeDriver;\nimport org.testng.annotations.AfterClass;\nimport org.testng.annotations.AfterGroups;\nimport org.testng.annotations.AfterMethod;\nimport org.testng.annotations.AfterSuite;\nimport org.testng.annotations.AfterTest;\nimport org.testng.annotations.BeforeClass;\nimport org.testng.annotations.BeforeGroups;\nimport org.testng.annotations.BeforeMethod;\nimport org.testng.annotations.BeforeSuite;\nimport org.testng.annotations.BeforeTest;\nimport org.testng.annotations.Test;\n\npublic class AnnotationsTestNG {\n\n\t\n\t\tpublic WebDriver driver;\n\t\tpublic String url=\"https:\/\/www.lambdatest.com\/\";\n\t\t\n\t@BeforeSuite\n\tpublic void setUp()\n\t{\t\n\t\tSystem.setProperty(\"webdriver.chrome.driver\", \"C:\\\\Users\\\\navyug\\\\workspace\\\\QAPractise\\\\src\\\\ChromeDriver\\\\chromedriver.exe\");\n\t\tdriver=new ChromeDriver();\n\t\tdriver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);\n\t\tSystem.out.println(\"The setup process is completed\");\n\t}\n\t\n\t@BeforeTest\n\tpublic void profileSetup()\n\t{\n\t\tdriver.manage().window().maximize();\n\t\tSystem.out.println(\"The profile setup process is completed\");\n\t\t\n\t}\n\t\n\t@BeforeClass\n\tpublic void appSetup()\n\t{\n\t\tdriver.get(url);\n\t\tSystem.out.println(\"The app setup process is completed\");\n\t}\n\t\n\t@BeforeMethod\n\tpublic void checkLogin()\n\t{\n\t\t  driver.get(\"https:\/\/accounts.lambdatest.com\/login\");\n\t\t  driver.findElement(By.xpath(\"\/\/input[@name='email']\")).sendKeys(\"sadhvisingh24@gmail.com\");\n\t\t  driver.findElement(By.xpath(\"\/\/input[@name='password']\")).sendKeys(\"activa9049\");\n\t\t  driver.findElement(By.xpath(\"\/\/*[@id='app']\/section\/form\/div\/div\/button\")).click();\n\t\t  System.out.println(\"The login process on lamdatest is completed\");\n\t}\n\t\n\t@Test(groups=\"urlValidation\")\n\tpublic void testCurrentUrl() throws InterruptedException\n\t{\n\t\tdriver.findElement(By.xpath(\"\/\/*[@id='app']\/header\/aside\/ul\/li[4]\/a\")).click();\n\t\tThread.sleep(6000);\n\t\tString currentUrl= driver.getCurrentUrl();\n\t\tassertEquals(currentUrl, \"https:\/\/automation.lambdatest.com\/timeline\/?viewType=build&amp;page=1\", \"url did not matched\");\n\t\tSystem.out.println(\"The url validation test is completed\");\n\t}\n\t\n\t@AfterMethod\n\tpublic void screenShot() throws IOException\n\t{\n\t\tTakesScreenshot scr= ((TakesScreenshot)driver);\n\t    File file1= scr.getScreenshotAs(OutputType.FILE);\n\t        \n\t    FileUtils.copyFile(file1, new File(\"C:\\\\Users\\\\navyug\\\\workspace\\\\QAPractise\\\\test-output\\\\test1.PNG\"));\n\t    System.out.println(\"Screenshot of the test is taken\");\n\t}\n\t\n\t@AfterClass\n\tpublic void closeUp()\n\t{\n\t\tdriver.close();\n\t\tSystem.out.println(\"The close_up process is completed\");\n\t}\n\t\n\t@AfterTest\n\tpublic void reportReady()\n\t{\n\t\tSystem.out.println(\"Report is ready to be shared, with screenshots of tests\");\n\t}\n\t\n\t@AfterSuite\n\tpublic void cleanUp()\n\t{\n\t\t\n\t\tSystem.out.println(\"All close up activities completed\");\n\t}\n\t\n\t@BeforeGroups(\"urlValidation\")\n    public void setUpSecurity() {\n        System.out.println(\"url validation test starting\");\n    }\n  \n    @AfterGroups(\"urlValidation\")\n    public void tearDownSecurity() {\n        System.out.println(\"url validation test finished\");\n    }\n\t\n\t\n\t\n}<\/pre>\n<h3 class=\"wp-block-heading\">TestNG Report:<\/h3>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/changeimage1-1-1024x550.png\" alt=\"TestNG Annotations\" class=\"wp-image-91339\" width=\"768\" height=\"413\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/changeimage1-1-1024x550.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/changeimage1-1-300x160.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/changeimage1-1-768x412.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/changeimage1-1.png 1364w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\">Console Output:<\/h3>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/121console_output_1-1024x552.png\" alt=\"TestNG Annotations\" class=\"wp-image-91340\" width=\"768\" height=\"414\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/121console_output_1-1024x552.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/121console_output_1-300x162.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/121console_output_1-768x414.png 768w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/accounts.lambdatest.com\/register\/\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Adword-2-1.jpg\" alt=\"TestNG Annotations\" class=\"wp-image-91341\" width=\"698\" height=\"135\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Adword-2-1.jpg 930w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Adword-2-1-300x58.jpg 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Adword-2-1-768x149.jpg 768w\" sizes=\"(max-width: 698px) 100vw, 698px\" \/><\/a><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">Execution Sequence Of Annotations In TestNG For Selenium<\/h2>\n<p>All annotations described above are executed on runtime in the following order:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ul class=\"wp-block-list\">\n<li>BeforeSuite<\/li>\n<li>BeforeTest<\/li>\n<li>BeforeClass<\/li>\n<li>BeforeGroups<\/li>\n<li>BeforeMethod<\/li>\n<li>Test<\/li>\n<li>AfterMethod<\/li>\n<li>AfterGroups<\/li>\n<li>AfterClass<\/li>\n<li>AfterTest<\/li>\n<li>AfterSuite<\/li>\n<\/ul>\n<p>Here is an image of the basic workflow of these annotations:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/console-output.png\" alt=\"TestNG Annotations\" class=\"wp-image-91342\" width=\"759\" height=\"245\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/console-output.png 1012w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/console-output-300x97.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/console-output-768x247.png 768w\" sizes=\"(max-width: 759px) 100vw, 759px\" \/><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">Attributes Used With Annotations In TestNG<\/h2>\n<p>These test annotations in TestNG have multiple attributes that can be used for our test method. The attributes further help in defining our tests and help in providing clarity in terms of execution flow of the different test\u2019s method used in the TestNG class. Listing them below:<\/p>\n<ul class=\"wp-block-list\">\n<li><b>Description:<\/b> It defines the test method. One can define what a method does via the description. For example,<code> @Test(description=\u201dthis test validates the login functionality\u201d)<\/code>.<\/li>\n<li><b>alwaysRun:<\/b> this attribute when used with a test method ensures it always run irrespective of the fact even if the parameters on which the method depends fails. When the value is set to true this method will always execute. For example, @Test(alwaysRun= true).<\/li>\n<li><b>dataProvider:<\/b> This attribute is set to provide data from the dataProvider annotated test to the test provided with this attribute. For example, let\u2019s say you intent to run your tests on multiple cross browsers, where a dataProvider annotated test is written which contains multiple inputs of browsers and their corresponding versions. In this case the test containing this attribute will use those inputs of data to run you tests on multiple browsers. Syntax for the same is, @Test(dataProvider=\u201dcross browser testing\u201d).<\/li>\n<li><b>dependsOnMethods:<\/b> This attribute provides details to the execution flow, wherein the test is executed only if its dependent method mentioned in the attribute is executed. In case the test on which the method depends on is failed or not executed, the test is skipped from the execution. For example, @Test(dependsOnmethod=\u201dLogin\u201d).<\/li>\n<li><b>groups:<\/b> This attribute helps to groups your test methods focusing onto a single functionality into one group. For example @Test(groups=\u201dPayment_Module\u201d). This attribute also helps in the longer run when one can choose to ignore few groups during the execution cycle and chose over the other groups. All one need to do is mention the included groups in the TestNG.xml file within the include tag whereas the excluded groups can be defined using the exclude tag in the xml file.<\/li>\n<li><b>dependsOnGroups:<\/b> this attribute performs the above two attributes functions in collation i.e. it defines the test method with the attribute \u2018dependsOn\u2019 the defined groups. Once that group of tests are run, only post that this annotated method would execute. For example, @Test(dependsOnMethods = \u201cPayment_Module\u201d ).<\/li>\n<li><b>priority:<\/b> This attribute helps us to defined priority of the test\u2019s methods. When TestNG executes the @Test annotated method, it may do so in random order. In a scenario where you wish that your @Test annotated method runs in a desired sequence you can use the priority attribute. The default priority of all test methods is 0. Priorities in ascending order are scheduled first for execution for example, @Test(priority=1), @Test(priority=2), in this case test with priority equal to one will be executed first then the test with priority as 2.<\/li>\n<li><b>enabled:<\/b> This attribute comes into picture, when you have an intent to ignore a particular test method and don\u2019t want to execute it. All you need to do is set this attribute to false. For example, @Test(enabled= false).<\/li>\n<li><b>timeout:<\/b> This attribute helps to define the time a particular test should take to execute, in case it exceeds the time defined by the attribute, the test method would terminate and will fail with an exception marked as org.testng.internal.thread.ThreadTimeoutException. For example, @Test(timeOut= 500). <b>Please note the time specified is in milliseconds.<\/b><\/li>\n<li><b>InvocationCount:<\/b> This attribute works exactly like the loop. Based on the attribute set across the test method, it would execute that method those number of times. For example, @Test(invocationCount = 5), this would execute the test 5 times.<\/li>\n<li><b>InvocationTimeOut:<\/b> this attribute is used in unison with the above invocationCount attribute. Based on the set value of this attribute along with the invocationCount, this ensures the test runs the number of times specified as per the invocationCount in the defined time set by the invocationTimeOut attribute. For example, @Test(invocationCount =5,invocationTimeOut = 20 ).<\/li>\n<li><b>expectedExceptions: <\/b> this attribute helps to handle the exception the test method is expected to throw. In case the one defined in the attribute is set and thrown by the test method it is passed else any other exception not stated in the attribute and thrown by the test method, would make the test method fail. For example, @Test(expectedExceptions = {ArithmeticException.class }).<\/li>\n<\/ul>\n<p>The above defined are the attributes used with the annotations in TestNG for Selenium. Below is the code snippet showcasing the use of the above attributes:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">import static org.testng.Assert.assertEquals;\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.concurrent.TimeUnit;\nimport org.apache.commons.io.FileUtils;\nimport org.openqa.selenium.By;\nimport org.openqa.selenium.OutputType;\nimport org.openqa.selenium.TakesScreenshot;\nimport org.openqa.selenium.WebDriver;\nimport org.openqa.selenium.WebElement;\nimport org.openqa.selenium.chrome.ChromeDriver;\nimport org.testng.annotations.AfterClass;\nimport org.testng.annotations.AfterGroups;\nimport org.testng.annotations.AfterMethod;\nimport org.testng.annotations.AfterSuite;\nimport org.testng.annotations.AfterTest;\nimport org.testng.annotations.BeforeClass;\nimport org.testng.annotations.BeforeGroups;\nimport org.testng.annotations.BeforeMethod;\nimport org.testng.annotations.BeforeSuite;\nimport org.testng.annotations.BeforeTest;\nimport org.testng.annotations.Test;\n\npublic class AnnotationsTest {\n\n\tpublic WebDriver driver;\n\tpublic String url=\"https:\/\/www.lambdatest.com\/\";\n\t\n\t@BeforeSuite\n\tpublic void setUp()\n\t{\n\t\tSystem.setProperty(\"webdriver.chrome.driver\", \"C:\\\\Users\\\\navyug\\\\workspace\\\\QAPractise\\\\src\\\\ChromeDriver\\\\chromedriver.exe\");\n\t\tdriver=new ChromeDriver();\n\t\tSystem.out.println(\"The setup process is completed\");\n\t}\n\t\n\t@BeforeTest\n\tpublic void profileSetup()\n\t{\n\t\tdriver.manage().window().maximize();\n\t\tSystem.out.println(\"The profile setup process is completed\");\n\t\t\n\t}\n\t\n\t@BeforeClass\n\tpublic void appSetup()\n\t{\n\t\tdriver.get(url);\n\t\tSystem.out.println(\"The app setup process is completed\");\n\t}\n   \n\t\n\t@Test(priority=2)\n\tpublic void checkLogin()\n\t{\n\t\t  driver.get(\"https:\/\/accounts.lambdatest.com\/login\");\n\t\t  driver.findElement(By.xpath(\"\/\/input[@name='email']\")).sendKeys(\"sadhvisingh24@gmail.com\");\n\t\t  driver.findElement(By.xpath(\"\/\/input[@name='password']\")).sendKeys(\"xxxxx\");\n\t\t  driver.findElement(By.xpath(\"\/\/*[@id='app']\/section\/form\/div\/div\/button\")).click();\n\t\t  System.out.println(\"The login process on lamdatest is completed\");\n\t}\n\t\n\t@Test(priority=0 ,description= \"this test validates the sign-up test\")\n\tpublic void signUp() throws InterruptedException\n\t{\n\t\tWebElement link= driver.findElement(By.xpath(\"\/\/a[text()='Free Sign Up']\"));\n\t\tlink.click();\n\t\tWebElement organization=driver.findElement(By.xpath(\"\/\/input[@name='organization_name']\"));\n\t\torganization.sendKeys(\"LambdaTest\");\n\t\tWebElement firstName=driver.findElement(By.xpath(\"\/\/input[@name='name']\"));\n\t\tfirstName.sendKeys(\"Test\");\n\t\tWebElement email=driver.findElement(By.xpath(\"\/\/input[@name='email']\"));\n\t\temail.sendKeys(\"User622@gmail.com\");\n\t\tWebElement password=driver.findElement(By.xpath(\"\/\/input[@name='password']\"));\n\t\tpassword.sendKeys(\"TestUser123\");\n\t\tWebElement phoneNumber=driver.findElement(By.xpath(\"\/\/input[@name='phone']\"));\n\t\tphoneNumber.sendKeys(\"9412262090\");\n\t\tWebElement termsOfService=driver.findElement(By.xpath(\"\/\/input[@name='terms_of_service']\"));\n\t\ttermsOfService.click();\n\t\tWebElement button=driver.findElement(By.xpath(\"\/\/button[text()='Signup']\"));\n\t\tbutton.click();\n        \n\t\t\n\t\t\n\t\t\n\t}\n\t\n\t@Test(priority=3, alwaysRun= true, dependsOnMethods=\"check_login\", description=\"this test validates the URL post logging in\" , groups=\"url_validation\")\n\tpublic void testCurrentUrl() throws InterruptedException\n\t{\n\t\tdriver.findElement(By.xpath(\"\/\/*[@id='app']\/header\/aside\/ul\/li[4]\/a\")).click();\n\t\tString currentUrl= driver.getCurrentUrl();\n\t\tassertEquals(current_url, \"https:\/\/automation.lambdatest.com\/timeline\/?viewType=build&amp;page=1\", \"url did not matched\");\n\t\tSystem.out.println(\"The url validation test is completed\");\n\t}\n\t\n\t@Test(priority=1, description = \"this test validates the logout functionality\" ,timeOut= 25000)\n\tpublic void logout() throws InterruptedException\n\t{\n\t\tThread.sleep(6500);\n\t\t driver.findElement(By.xpath(\"\/\/*[@id='userName']\")).click();\n\t\t driver.findElement(By.xpath(\"\/\/*[@id='navbarSupportedContent']\/ul[2]\/li\/div\/a[5]\")).click();\t\n\t}\n\t\n\t@Test(enabled=false)\n\tpublic void skipMethod()\n\t{\n\t\tSystem.out.println(\"this method will be skipped from the test run using the attribute enabled=false\");\n\t}\n\t\n\t@Test(priority=6,invocationCount =5,invocationTimeOut = 20)\n\tpublic void invocationcountShowCaseMethod()\n\t{\n\t\tSystem.out.println(\"this method will be executed by 5 times\");\n\t}\n\t\n\t\n\t\n\t@AfterMethod()\n\tpublic void screenshot() throws IOException\n\t{\n\t\tTakesScreenshot scr= ((TakesScreenshot)driver);\n        File file1= scr.getScreenshotAs(OutputType.FILE);\n        \n       FileUtils.copyFile(file1, new File(\"C:\\\\Users\\\\navyug\\\\workspace\\\\QAPractise\\\\test-output\\\\test1.PNG\"));\n       System.out.println(\"Screenshot of the test is taken\");\n\t}\n\t\n\t@AfterClass\n\tpublic void closeUp()\n\t{\n\t\tdriver.close();\n\t\tSystem.out.println(\"The close_up process is completed\");\n\t}\n\t\n\t@AfterTest\n\tpublic void reportReady()\n\t{\n\t\tSystem.out.println(\"Report is ready to be shared, with screenshots of tests\");\n\t}\n\t\n\t@AfterSuite\n\tpublic void cleanUp()\n\t{\n\t\t\n\t\tSystem.out.println(\"All close up activities completed\");\n\t}\n\t\n\t@BeforeGroups(\"urlValidation\")\n    public void setUpSecurity() {\n        System.out.println(\"url validation test starting\");\n    }\n  \n    @AfterGroups(\"urlValidation\")\n    public void tearDownSecurity() {\n        System.out.println(\"url validation test finished\");\n    }\n\t\n\t\n\t\n}<\/pre>\n<h3 class=\"wp-block-heading\">Console Output:<\/h3>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/console_output_2-1024x576.png\" alt=\"TestNG Annotations\" class=\"wp-image-91343\" width=\"768\" height=\"432\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/console_output_2-1024x576.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/console_output_2-300x169.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/console_output_2-768x432.png 768w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\">TestNG Report:<\/h3>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/TestNgReport-1024x576.png\" alt=\"TestNG Annotations\" class=\"wp-image-91344\" width=\"768\" height=\"432\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/TestNgReport-1024x576.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/TestNgReport-300x169.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/TestNgReport-768x432.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/TestNgReport.png 1366w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">Annotations In TestNG For Desired Purpose<\/h2>\n<p>There are more annotations than the ones defined above, which are used for desired purpose only.<\/p>\n<h3 class=\"wp-block-heading\">@DataProvider<\/h3>\n<p>This annotated method is used for supplying data to the test method in which the dataProvider attribute is defined. This annotated method helps in creating a data driven framework where multiple sets of input values can be given which returns a 2D array or object. <b>@DataProvider annotation in TestNG comes with two attributes.<\/b><\/p>\n<ul class=\"wp-block-list\">\n<li><b>name-<\/b> this attribute is used to provide name to the dataprovider. If not set it defaults to the name of the method provided.<\/li>\n<li><b>parallel-<\/b>this is one attribute that helps in running your tests in parallel with different variation of data. This attribute is one of the reasons to make TestNG more powerful to Junit. Its default value is false.<\/li>\n<\/ul>\n<p>Below is the code snippet indicating the use of @DataProvider annotation with name and parallel attribute set to it.<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@DataProvider(name=\"SetEnvironment\", parallel=true)\npublic Object[][] getData(){\n\nObject[][] browserProperty = new Object[][]{\n\n\n{Platform.WIN8, \"chrome\", \"70.0\"},\n{Platform.WIN8, \"chrome\", \"71.0\"}\n};\nreturn browserProperty;\n\n}<\/pre>\n<h3 class=\"wp-block-heading\">@Factory<\/h3>\n<p>This annotation helps to run multiple test classes through a single test class. It basically defines and create tests dynamically.<\/p>\n<p>The below code snippet indicates the use of @Factory annotation that helps calls the test method class.<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">package ChromeDriver;\n\nimport org.testng.annotations.Test;\n\npublic class FactorySimplyTest1 {\n\n\t@Test\n\tpublic void testMethod1() {\n\t\tSystem.out.println(\"This is to test for method 1 for Factor Annotation\");\n\t\n}}\n\n\npackage ChromeDriver;\n\nimport org.testng.annotations.Test;\n\npublic class FactorySimpleTest2 {\n\n\t@Test\n\tpublic void testMethod2() {\n\t\tSystem.out.println(\"This is to test for method 2 for Factor Annotation\");\n\t\n\t\n}\n}\n\n\npackage ChromeDriver;\n\nimport org.testng.annotations.Factory;\nimport org.testng.annotations.Test;\n\npublic class FactoryAnnotation {\n\n\t@Factory()\n\t@Test\n\tpublic Object[] getTestFactoryMethod() {\n\t\tObject[] factoryTest = new Object[2];\n\t\tfactoryTest[0] = new FactorySimplyTest1();\n\t\tfactoryTest[1] = new FactorySimpleTest2();\n\t\treturn factoryTest;\n\t}\n\t\n}<\/pre>\n<h3 class=\"wp-block-heading\">Console Output:<\/h3>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Factory_Console-1024x576.png\" alt=\"TestNG Annotations\" class=\"wp-image-91345\" width=\"768\" height=\"432\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Factory_Console-1024x576.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Factory_Console-300x169.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Factory_Console-768x432.png 768w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\">@Parameters<\/h3>\n<p>This annotation helps you pass parameters to your tests directly via the testNG.xml file. Usually this is preferred when you have limited data sets to try on your tests. In case of complicated and large data sets @dataProvider annotation is preferred or excel.<\/p>\n<p>The below code snippet showcase the same:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">@Parameters({ \"username\", \"password\"})\n\t@Test()\n\tpublic void checkLogin(String username, String password)\n\t{\n\t\t  driver.get(\"https:\/\/accounts.lambdatest.com\/login\");\n\t\t  driver.findElement(By.xpath(\"\/\/input[@name='email']\")).sendKeys(username);\n\t\t  driver.findElement(By.xpath(\"\/\/input[@name='password']\")).sendKeys(password);\n\t\t  driver.findElement(By.xpath(\"\/\/*[@id='app']\/section\/form\/div\/div\/button\")).click();\n\t\t  System.out.println(\"The login process on lamdatest is completed\");\n\t}<\/pre>\n<p>The parameter values are defined in the TestNG.xml file as below:<\/p>\n<pre class=\"wp-block-preformatted brush:bash\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;!DOCTYPE suite SYSTEM \"http:\/\/testng.org\/testng-1.0.dtd\"&gt;\n&lt;suite name=\"Suite\"&gt;\n  &lt;test thread-count=\"5\" name=\"Annotations\"&gt;\n  \n        &lt;parameter name=\"username\"  value=\"sadhvisingh24@gmail.com\" \/&gt;\n        &lt;parameter name=\"password\"  value=\"XXXXX\" \/&gt;\n        \n        &lt;classes&gt;\n            &lt;class name=\"Parameter_annotation\"\/&gt;\n        &lt;\/classes&gt;\n  \n  &lt;\/test&gt; &lt;!-- Annotations --&gt;\n&lt;\/suite&gt; &lt;!-- Suite --&gt;<\/pre>\n<h3 class=\"wp-block-heading\">@Listener<\/h3>\n<p>This annotation helps in logging and reporting. We have multiple listeners like:<\/p>\n<ul class=\"wp-block-list\">\n<li><b>IExecutionListener<\/b><\/li>\n<li><b>IAnnotationTransformer<\/b><\/li>\n<li><b>ISuiteListener<\/b><\/li>\n<li><b>ITestListener<br \/><\/b><\/li>\n<\/ul>\n<p>But to go in depth with these listeners and their uses would be a talk for another blog. I will be writing one soon, so stay tuned.<\/p>\n<h2 class=\"wp-block-heading\">That Was All!<\/h2>\n<p>The key point to note while working with all these annotations and attributes is your system should have java 1.5 version or higher as these annotations are not supported for all lower versions of java and you may tend to receive error for them.<\/p>\n<p>All the above mentioned annotations and attributes of TestNG helps to provide better structuring and readability to the code. It helps provide detailed reports that makes status reporting part even easier and useful. Use of these annotations in TestNG for Selenium completely depend on your business requirements. Hence, choosing the right ones for the right use is important.Try out these annotations in <a href=\"https:\/\/www.lambdatest.com\/support\/docs\/testng-with-selenium-running-java-automation-scripts-on-lambdatest-selenium-grid\/\" target=\"_blank\" rel=\"noopener noreferrer\">TestNG on LambdaTest Selenium Grid<\/a> now!<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Adword-Cyber2-3.jpg\" alt=\"\" class=\"wp-image-91346\" width=\"698\" height=\"135\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Adword-Cyber2-3.jpg 930w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Adword-Cyber2-3-300x58.jpg 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/04\/Adword-Cyber2-3-768x149.jpg 768w\" sizes=\"(max-width: 698px) 100vw, 698px\" \/><\/figure>\n<\/div>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Java Code Geeks with permission by Sadhvi Singh, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">JCG program<\/a>. See the original article here: <a href=\"https:\/\/www.lambdatest.com\/blog\/complete-guide-on-testng-annotations-for-selenium-webdriver\/\" target=\"_blank\" rel=\"noopener noreferrer\">Complete Guide On TestNG Annotations For Selenium WebDriver<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>TestNG is a testing framework created by C\u00e9dric Beust and helps to cater a lot of our testing needs. It is widely used in Selenium. Wondering on what NG stands for? Well, it refers to \u2018Next Generation\u2019. TestNG is similar to Junit but is more powerful to it when it comes to controlling the execution &hellip;<\/p>\n","protected":false},"author":86855,"featured_media":231,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[287,342],"class_list":["post-91315","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-selenium","tag-testng"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Complete Guide On TestNG Annotations For Selenium WebDriver - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about TestNG Annotations? Check our article presenting a Complete Guide to TestNG Annotations For Selenium WebDriver.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Complete Guide On TestNG Annotations For Selenium WebDriver - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about TestNG Annotations? Check our article presenting a Complete Guide to TestNG Annotations For Selenium WebDriver.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-04-30T07:00:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sadhvi Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sadhvi Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html\"},\"author\":{\"name\":\"Sadhvi Singh\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c161d28b654426f5f53205d3e5741592\"},\"headline\":\"Complete Guide On TestNG Annotations For Selenium WebDriver\",\"datePublished\":\"2019-04-30T07:00:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html\"},\"wordCount\":2206,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"keywords\":[\"Selenium\",\"TestNG\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html\",\"name\":\"Complete Guide On TestNG Annotations For Selenium WebDriver - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"datePublished\":\"2019-04-30T07:00:23+00:00\",\"description\":\"Interested to learn about TestNG Annotations? Check our article presenting a Complete Guide to TestNG Annotations For Selenium WebDriver.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/04\\\/complete-guid-testng-annotations-selenium-webdriver.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Complete Guide On TestNG Annotations For Selenium WebDriver\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c161d28b654426f5f53205d3e5741592\",\"name\":\"Sadhvi Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g\",\"caption\":\"Sadhvi Singh\"},\"description\":\"Sadhvi Singh is a QA Manager. In 7 years of her professional journey, she has worked on multiple domains and testing techniques like Automation testing, Database testing, API testing, Manual testing, and Security testing. With multiple tools exposure added to her experience, she has skilled herself further through her two major accolades at International level through ISTQB with foundation and advanced levels. She has a technical blog named as qavibes.blogspot.com where she caters to all the challenges offered in the day to day journey of the quality assurance aspirants. In her spare time, she also works as a technical trainer and mentor to many budding QA professionals.\",\"sameAs\":[\"https:\\\/\\\/www.lambdatest.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/sadhvi-singh\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Complete Guide On TestNG Annotations For Selenium WebDriver - Java Code Geeks","description":"Interested to learn about TestNG Annotations? Check our article presenting a Complete Guide to TestNG Annotations For Selenium WebDriver.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html","og_locale":"en_US","og_type":"article","og_title":"Complete Guide On TestNG Annotations For Selenium WebDriver - Java Code Geeks","og_description":"Interested to learn about TestNG Annotations? Check our article presenting a Complete Guide to TestNG Annotations For Selenium WebDriver.","og_url":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2019-04-30T07:00:23+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","type":"image\/jpeg"}],"author":"Sadhvi Singh","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Sadhvi Singh","Est. reading time":"18 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html"},"author":{"name":"Sadhvi Singh","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c161d28b654426f5f53205d3e5741592"},"headline":"Complete Guide On TestNG Annotations For Selenium WebDriver","datePublished":"2019-04-30T07:00:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html"},"wordCount":2206,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","keywords":["Selenium","TestNG"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html","url":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html","name":"Complete Guide On TestNG Annotations For Selenium WebDriver - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","datePublished":"2019-04-30T07:00:23+00:00","description":"Interested to learn about TestNG Annotations? Check our article presenting a Complete Guide to TestNG Annotations For Selenium WebDriver.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2019\/04\/complete-guid-testng-annotations-selenium-webdriver.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Complete Guide On TestNG Annotations For Selenium WebDriver"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c161d28b654426f5f53205d3e5741592","name":"Sadhvi Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bb8228ad0652dddd0649786b1b414bd85838ad14e20d439a8ee4aa51d416dba3?s=96&d=mm&r=g","caption":"Sadhvi Singh"},"description":"Sadhvi Singh is a QA Manager. In 7 years of her professional journey, she has worked on multiple domains and testing techniques like Automation testing, Database testing, API testing, Manual testing, and Security testing. With multiple tools exposure added to her experience, she has skilled herself further through her two major accolades at International level through ISTQB with foundation and advanced levels. She has a technical blog named as qavibes.blogspot.com where she caters to all the challenges offered in the day to day journey of the quality assurance aspirants. In her spare time, she also works as a technical trainer and mentor to many budding QA professionals.","sameAs":["https:\/\/www.lambdatest.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/sadhvi-singh"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/91315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/86855"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=91315"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/91315\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/231"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=91315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=91315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=91315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}