Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Automation Testing Using TestNG

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 371
    Comment on it

    TestNG is a testing framework. It is powerful and easier to use to test the appliication we can automatically test the Application and generate the necessary documentation. The TestNG can have more functionality as comparing to JUnit and NUnit. TestNG is designed to implement all categories of tests like:- unit, functional, end-to-end and integration Testing etc. Here the Below code snippet to Run TestNG Using Java.

    package TestNG;
    
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.support.ui.Select;
    import org.testng.annotations.AfterTest;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Test;
    
    
    
    public class TestNGClass {
    
        WebDriver driver=new FirefoxDriver();
    
    
        @BeforeTest
        public void BeforeTestingApp()
        {
            driver.get("http://www.calculator.net");
            driver.manage().window().maximize();
        }
    
        @Test
        public void TestApp() 
        {
            driver.findElement(By.xpath(".//*[@id='menu']/div[3]/a/img")).click();
            driver.findElement(By.xpath(".//*[@id='menu']/div[4]/div[3]/a")).click();
            driver.findElement(By.id("cpar1")).sendKeys("50");
          driver.findElement(By.id("cpar2")).sendKeys("10");
          driver.findElement(By.xpath(".//*[@id='content']/table/tbody/tr/td[2]/input")).click();
    
          String result=driver.findElement(By.xpath(".//*[@id='content']/p[2]/span/font/b")).getText();
          System.out.println(result);
          if (result.equals("5")){
             System.out.println("Pass");
          }
          else{
             System.out.println("Fail");
          }
    
    
    
        }
    
        @AfterTest
        public void AfterTestingApp()
        {
            //driver.close();
        }
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: