Tuesday, April 4, 2017

Installing TestNG in Eclipse and creating first Test

1)       Launch Eclipse > On the menu bar, click Help > Choose the "Eclipse Marketplace..." option 

2)       In the Eclipse Marketplace dialog box, type TestNG in the search box and press the search button
















3)       Click on Install > A new window will open to confirm the options. Don’t make any change and click “Confirm”


4)       Click next on every other window. Accept the license. Restart the eclipse. After the restart, right-click on the project name and check the following two options.










5) Now click “Create TestNG class”to add a new class. And copy the following code

public class DummyTest1

{

   public WebDriver driver;

  @Test

  public void main()
  {
     driver.findElement(By.name("userName")).sendKeys("mercury");
     driver.findElement(By.name("password")).sendKeys("mercury");
     driver.findElement(By.name("login")).click();
  }

  @BeforeMethod

  public void beforeMethod()
  {
      driver = new FirefoxDriver();
      driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
      driver.get("http://newtours.demoaut.com/");
  }

  @AfterMethod

  public void afterMethod()
  {
       driver.quit();
  }

}

6)       Now click Run > Run as > TestNG Test






No comments:

Post a Comment