Order of TestNG Annotations!!!!!

7:58 PM 0 Comments













The Order of the below Testng Annotations is important. Lets look into them below:
@BeforeSuite
@BeforeTest
@BeforeClass
@BeforeGroups
@BeforeMethod
@AfterMethod
@AfterGroups
@AfterClass
@AfterTest
@AfterSuite

Example for @BeforeMethod & @AfterMethod:


Scenario1:

Suppose for every test-case to execute the pre-condition as login and post-condition as log-out then we have to use as follows:

LoginApp.java

public class LoginApp 
{
        @BeforeMethod
         public void Login()
        {
              System.out.println("In Login Method");
         }
          @AfterMethod
          public void Logout()
         {
               System.out.println("In Logout Method"); 
         }
        @Test
         public void testcase1()
        {
               System.out.printl("testcase1");
         }
         @Test
         public void testcase2()
        {
               System.out.printl("testcase2");
         }
}

Order of Execution:

Login()
testcase1()
Logout()
Login()
testcase2()
Logout()


Example for @BeforeClass & @AfterClass:

Scenario2:

Suppose for all the test-cases the pre-condition say creating a driver instance should be invoked only and the post-condition say quitting the browser once after the execution of all the @Test methods is done.

LoginApp.java

public class LoginApp 
{
         WebDriver driver;
        @BeforeClass
         public void invokeBrowser()
        {
             driver = new FirefoxDriver();
             driver.get("http://www.Facebook.com");
         }
          @AfterClass
          public void closeBrowser()
         {
              driver.quit();
         }
        @Test
         public void testcase1()
        {
               System.out.printl("testcase1");
         }
         @Test
         public void testcase2()
        {
               System.out.printl("testcase2");
         }
}

Order of Execution:

invokeBrowser()
testcase1()
testcase2()
closeBrowser()

Example for @BeforeTest & @AfterTest:

Scenario 3:
Suppose for example if we want to execute the same program on multiple browsers say IE and FF. In those cases we should have configuration file should be written as follows:


0 comments:

Inserting an Image as a hyperlink in Testng Reporter Log

7:58 PM 0 Comments


0 comments:

Installation of Testng plugin in Eclipse

7:55 PM 0 Comments

Installing TestNG in Eclipse

Step 1


• Launch Eclipse.
• On the menu bar, click Help.
• Choose the "Eclipse Marketplace..." option.

Step 2

• Click on Next button.

Step 3

• Enter the text as ‘testng’ and click on ‘Go’ button. In the results next to testng you will find an ‘install’ button please click on install button. Note: In my system I already have testng so it shows two options as ‘update’ or ‘uninstall’.

Step 4

Restart Eclipse

Step 5

After restart, verify if TestNG was indeed successfully installed. Click Window > Preferences and see if TestNG is included on the Preferences list.

0 comments:

Usage of Xpath Locator in Selenium WebDriver!!!

8:03 PM 0 Comments


In Selenium they are 8 locators which helps in identifying the objects. 

 1. id
 2. name
 3. tagName
 4. className
 5. partialLinkText
 6. linkText
 7. xpath
 8. cssSelector

You Tube to xpath video->

SeleniumWebDriver Xpath Part1

0 comments: