Selenium WebDriver – Insert Verification Point

A verification point is a specialized step that compares two values and reports the result. A verification point compares the actuals from the test run, with the expected results in the test case.

You use a checkpoint to:

  • Verify the state of an object
  • Confirm that an application performs as expected

A verification point checks whether an application responds appropriately when a user performs tasks correctly while testing application. A verification point ensures that a user is barred from performing certain tasks and confirms that invalid or incomplete data are flagged with appropriate messages.

Inserting a Verification Point

A verification point can be inserted in the WebDriver script. In this section we will lay out a test scenario in which we have expected result and we will try to automate that test scenario.

Test Scenario

Let us take a simple test case for automation from Google Search Application.

Test Objective: To verify that Selenium link is displayed while page open through Google search application.

Test Steps:

  1. Open to Google search application
  2. Enter the in text box and click Google search
  3. Click on link
  4. Verify that Selenium link is displayed in header section.

Expected Result :-   Selenium link should be displayed in header section.

How to Insert a verification Point

Step 1: Right click on your existing MyFrirstWebDriverTest.Java script, Select Copy.

Step 2: Select the tests package folder, right click and select paste


Step 3: In the Name Conflict dialog box, enter name of the script as VerificationPointTest and click OK


Step 4: Double click on the newly created “” script so that you can see the script.


Now we will insert a verification point.

Step 1: In the script go to the step after which user click the link in Google search application.


Step 2: Now let us find out the XPath or id value for the Selenium link field in the page. To do this, open your Firefox browser, open application URL, search and then click on page.

Step 3: In Firefox browser open Firebug add-on with Firepath view, Click on highlight option and select Location field.


We notice in the above snapshot that Xpath for link field is



Id = menu-item-4

Now we know the Xpath or id of the object to locate the object.

We would also need to find out the property value for this object which stores the value “Selenium”. We will again use Firebug to find this out.

Step 4: Click on DOM tab in  Firebug.

Step 5: To get the property name:

  • Click on the highlight icon
  • Then click on the link Selenium
  • Scroll down in the DOM tab to find out which property stores the value “Selenium”


In the above snapshot you will notice property name value is storing “Selenium”

Step 6: Now to insert a verification point in the script, we will insert the statement below:

String linkText = driver.findElement(By.xpath(“.//*[@id=’menu-item-4′]/a”)).getAttribute(“innerText”);

in the above statement –

driver.findElement – help to find the element based on locator

By.xpath(“(“.//*[@id=’menu-item-4′]/a”) – helps to locate element based on xpath.

getAttribute – helps us to get the desired property value of the Web Element.

innerText – is the property name which stores the actual value for location


Step 7: Now we would need to compare it with our expected value and report pass or fail. Insert the following statement after the getAttribute statement.

If Else statement is used as a conditional structure.

equalsIgnoreCase method is used for string comparison in java after ignoring the case of string.

System.out.println is used to print output to the cocsole.

Step 8: That’s it. Now we can perform Project > Clean and run the script by selecting the script, right click and select Run as Junit test. Verify the result in the Eclipse console.

Understand how to implement a Few Common Validation

The common type of validation are:

  • Is the page title as expected?
  • Does text exist on the Page/Webelement and is as expected?

Let us look at how to achieve each of these using the WebDriver API.

Page Title Validation

You can get the current page title simple by calling getTitle() on the WebDriver instance. Here is a simple test that would verify the title –

String pageTitle = driver.getTitle();

if (pageTitle.equalsIgnoreCase(AUTOMATION TUTORIAL”)) {

System.out.println(“Page title is correct. Actual page title is  ” + pageTitle);

} else {

System.out.println(“Page title is incorrect. Actual page title is  ” + pageTitle);


Page Element Validation

You can use the following approach for validating text within an element. Here we find the element using one of the locator strategies and then call getText() or getAttribute() on the element object returned.

For instance we want to check footer text of


We can use gettext method on the footer text field “© Copyright 2016. All Rights Reserved by”

using Firepath verify Xpath for the footer message  –


Xpath = html/body/footer/div[2]/div/div/div[1]/p

String sFootertext = driver.findElement(By.xpath(“html/body/footer/div[2]/div/div/div[1]/p”)).getText();

if (sFootertext.equalsIgnoreCase(“© Copyright 2016. All Rights Reserved by”)) {

sFootertext .out.println(“Footer text is correct. Actual Footer text is  ” + sFootertext );

} else {

sFootertext .out.println(“Footer text is incorrect. Actual Footer text is  ” + sFootertext );


Leave a Reply

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