Articles → SELENIUM → Assertions In Selenium

Assertions In Selenium



Assert.assertEquals(actual, expected);	

  1. Actual (string) – Actual value of the test.
  2. Expected (string) – Expected output of the test.


  1. Convert our application to TestNG application
  2. Write a code for assertion
  3. Run the application as TestNG application

Convert Our Application To Testng Application

Picture showing the Convert to TestNG option in eclipse
Click to Enlarge

Write A Code For Assertion

package com.FirstSeleniumProject;

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

public class MyClass {
    public void TestAnnotation() {
        WebDriver driver;
        String service = "IEDriverServer path";
        System.setProperty("", service);
        driver = new InternetExplorerDriver();

        Assert.assertEquals(driver.getTitle(), "Gyan Sangrah");

Run The Application As Testng Application

Picture showing how to run the application as TestNG application
Click to Enlarge

Picture showing the result of assertion in selenium
Click to Enlarge

Posted By  -  Karan Gupta
Posted On  -  Tuesday, April 18, 2017


Your Email Id  
Query/FeedbackCharacters remaining 250