This tutorial will explain how use the Assert Method in TestNG
Sample Code :
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
public class Tutorial6 {
@Test()
public void TC_1() {
System.setProperty("webdriver.chrome.driver", "D:\\YouTube\\TestNG\\Libs\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
String title = driver.getTitle();
System.out.println(title);
Assert.assertEquals(title, "Google" , "Asserting the Title");
boolean bol_searchbox = driver.findElement(By.name("q")).isDisplayed();
Assert.assertTrue(bol_searchbox , "Checking if the seachbox is displayed");
driver.close();
}
}
Watch video Assert Method - TestNG Tutorial 6 online without registration, duration hours minute second in high quality. This video was added by user Automation Zone 21 October 2018, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,382 once and liked it 21 people.