TestNG
.
TestNG is a testing system that beats the restrictions of another prominent testing structure called JUnit
. The "NG"
signifies Next Generation
. Most Selenium clients utilize this more than JUnit as a result of its favorable circumstances. There are such a variety of components of TestNG. Following are the features of TestNG.
TestNG
and click on Next
button, then another page will be opened, fill the data.
DemoTestNG.java
[java]
//following is an example for Selenium TestNG Framework
package TestNG;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
public class DemoTestNG {
public WebDriver driver = new FirefoxDriver();
String appUrl = "https://accounts.google.com";
@Test
public void gmailLogin() {
// launch the firefox browser and open the application url
driver.get("https://gmail.com");
// maximize the browser window
driver.manage().window().maximize();
String expectedTitle = " Sign in - Google Accounts ";
String actualTitle = driver.getTitle();
Assert.assertEquals(expectedTitle,actualTitle);
WebElement username = driver.findElement(By.id("Email"));
username.clear();
username.sendKeys("TestSelenium");
//enter a valid password in the password textbox
WebElement password = driver.findElement(By.id("Passwd"));
password.clear();
password.sendKeys("password123");
//click on the Sign in button
WebElement SignInButton = driver.findElement(By.id("signIn"));
SignInButton.click();
//close the web browser
driver.close();
}
}
[/java]
There is no need of main()
strategy while making test scripts utilizing TestNG. The project execution is done on the premise of explanations.Now run the code as follows.
Output will be as follows. Following result from console
.
Following is TestNG
result window.