Articles → SELENIUM → Assertions In Selenium
Assertions In Selenium
Purpose
Syntax
Assert.assertEquals(actual, expected);
- Actual (string) – Actual value of the test.
- Expected (string) – Expected output of the test.
Scenario
- Convert our application to TestNG application
- Write a code for assertion
- Run the application as TestNG application
Convert Our Application To Testng Application
Click to Enlarge
Write A Code For Assertion
package com.FirstSeleniumProject;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
public class MyClass {
@Test
public void TestAnnotation() {
WebDriver driver;
String service = "IEDriverServer path";
System.setProperty("webdriver.ie.driver", service);
driver = new InternetExplorerDriver();
driver.get("http://gyansangrah.com/");
Assert.assertEquals(driver.getTitle(), "Gyan Sangrah");
}
}
Run The Application As Testng Application
Click to Enlarge
Click to Enlarge