Verify browser title using TestNG

package usinghtmlunit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.testng.annotations.Test;

public class verifybrowsertitleusingtestng {

@Test
public void FacebookTitle()
{
WebDriver driver = new HtmlUnitDriver();

driver.get(“http://facebook.com”);

System.out.println(driver.getTitle());
}

}

Verify browser title using TestNG and Assert

package usinghtmlunit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

public class verifybrowsertitleusingtestngandassert {

@Test
public void FacebookTitle()
{
WebDriver driver = new HtmlUnitDriver();

driver.get(“http://facebook.com”);

String fbTitle = driver.getTitle();

Assert.assertTrue(fbTitle.contains(“Facebook”));

System.out.println(fbTitle);
}

@Test
public void FacebookTitlenew()
{
WebDriver driver = new HtmlUnitDriver();

driver.get(“http://facebook.com”);

String fbTitle = driver.getTitle();

Assert.assertTrue(fbTitle.contains(“Selenium”));

System.out.println(fbTitle);
}

}

Leave a Reply

Your email address will not be published. Required fields are marked *