@@ -0,0 +1,2427 @@
+package _10_WorkingWithAssertions;%0A%0Aimport org.openqa.selenium.By;%0Aimport org.openqa.selenium.Dimension;%0Aimport org.openqa.selenium.Point;%0Aimport org.openqa.selenium.WebDriver;%0Aimport org.openqa.selenium.WebElement;%0Aimport org.openqa.selenium.firefox.FirefoxDriver;%0Aimport org.testng.Assert;%0Aimport org.testng.annotations.Test;%0A%0A/**%0A * @summary This class gives a brief overview and demonstration of only some of%0A *          the TestNG Assertions%0A */%0Apublic class _01_Assertions %7B%0A%09// Declare a WebDriver%0A%09WebDriver driver;%0A%09// Declare a WebElement%0A%09WebElement element;%0A%09// Declare a Point%0A%09Point location;%0A%09// Declare a Dimension%0A%09Dimension size;%0A%09// Declare and define a URL%0A%09String url = %22http://the-internet.herokuapp.com%22;%0A%0A%09@Test%0A%09public void test() %7B%0A%09%09// Create a new WebDriver%0A%09%09driver = new FirefoxDriver();%0A%09%09// Navigate to the desired web page%0A%09%09driver.get(url);%0A%09%09// Grab the element under inspection%0A%09%09element = driver.findElement(By.linkText(%22Sortable Data Tables%22));%0A%0A%09%09// Assert that the element is not null%0A%09%09Assert.assertNotNull(element);%0A%09%09// Assert that the element is displayed%0A%09%09Assert.assertEquals(element.isDisplayed(), true);%0A%09%09// Assert that the element is not disabled%0A%09%09Assert.assertNotEquals(element.isEnabled(), false);%0A%09%09// Assert that the element's text matches that which is expected%0A%09%09Assert.assertEquals(element.getText(), %22Sortable Data Tables%22);%0A%09%09// Assert that the element's tag name is that which is expected%0A%09%09Assert.assertEquals(element.getTagName(), %22a%22);%0A%09%09// Assert that an element attribute matches that which is expected%0A%09%09Assert.assertEquals(element.getAttribute(%22href%22), url + %22/tables%22);%0A%0A%09%09/*%0A%09%09 * Run assertions on the location and height of the element. This can be%0A%09%09 * used as an alternate mean to determine if an object is visible.%0A%09%09 */%0A%09%09// Grab the elements x and y-coordinates%0A%09%09location = element.getLocation();%0A%09%09// Assert that the element's x-coordinate is greater than zero%0A%09%09Assert.assertTrue((location.x %3E 0));%0A%09%09// Assert that the element's y-coordinate is greater than zero%0A%09%09Assert.assertTrue((location.y %3E 0));%0A%09%09//Grab the element's height and width%0A%09%09size = element.getSize();%0A%09%09//Assert that the element's height is greater than zero%0A%09%09Assert.assertTrue((size.height %3E 0));%0A%09%09//Assert that the element's width is greater than zero%0A%09%09Assert.assertTrue((size.width %3E 0));%0A%0A%09%09//Close the browser%0A%09%09driver.close();%0A%09%09//Quit the driver%0A%09%09driver.quit();%0A%09%7D%0A%7D%0A

add class to demonstrate working with TestNG Assertions