Testing Datatable example

This page is about Testing Automation of Datatable jQuery plugin example.The Datatable uses very rich ui with table tag of the HTML. Therefore by learning this content, you can understand the technique to handle such an application with the Selenium and Junit.

In order to understand what test, please take a look at Datatable jQuery plugin before reading this page.

About test cases

In these test cases, we do following tests.


  • Paging works correctly
  • Full text search works correctly

These are not enough cases, but by learning them, you can understand how to implement other test cases.

Most of the necessary technique is how to use the xpath, and use pause when the table is loading data from server.

The evidense screen shot is stored at location below.


datatable testing evidence

Those screenshots a taken by Selenium program using taking screenshot technique.

Location of the source code

The source code to test this is in "org.alinous.test.html5.components" package.

source codes to test datatable

The "DataTableTest" class has the testing code of the JUnit.

Initialize WebDriver of the Selenium and Database

At the first of the JUnit Test class, we initialize and connect the WebDriver, and make the download folder empty. And set up database status by original data.

Paging test

This test case is to check the paging work correctly by checking the page's record.

Source code of this test case

This test case is to check the record's number and if the next page exist, go to the next page and check, iterate the operation.

The source code is below.

Full text search test

This test case is to check the full text search work correctly. By setting filter string into the search form and check the record appears in the datatable, and the number of records.

Source code of this test case

This test is simular to the Paging test. Before doing the paging test, set the search string and check the record with paging. In addition to that, check the record contains the search string on this case.

In order to work this test, the pause is necessary. It is because the web browser needs time to render the dom object. If you don't pause, you can't get correct web element in the test code.

Go to Top