Database Verification Using Selenium Webdriver



As far as Selenium is concerned, there is no direct facility given by Selenium to connect with any database to check any stored value. To check the saved value you have to connect to databases depending on used db like mysql, oracle etc. You have to use supported api to make connection to database first then execute query. When using Selenium to automate UI testing, we need to make sure any user data entered from the UI should be captured in the database. We can use database retrieve statement to retrieve data and then use the data to verify what is entered by the user. Considering the example of a user registration.

In our last Selenium blogs we learned below Some Selenium frameworks Concepts:

  • Part1: Data Driven Framework in Selenium Webdriver Using Apache POI
  • Part2: Passing data to DataProvider from Excel Sheet in TestNG
  • Part3: Creating ,Updating and Deleting Excel Workbook and Sheet By Selenium
Webdriver

We discussed some Advanced concepts like how we deal with Data Manipulation in Excel sheet by Selenium WebDriver. So moving ahead with our advance topics of selenium blog series we will introduce you with concepts of Database Testing using Selenium WebDriver.

We would discuss the basic process like Database Connection, executing queries, fetching data and disconnecting database instances etc. As we know that all the web applications need a backend to store the Data. Databases like MySQL, oracle, and SQL server are popularly use in these days

Here I take a example of Bookingcommerce in which i explain how user can register in bookingcommerce.com , So Bookingcommerce is basically a Saas based online booking and Appointment scheduling software.

Consider a following scenarios

1) In any application we make sure that the data entered by code is consistently reflected in our databases. Thus we are able to retrieve the information by executing a sql query and verify the retrieved information against information we pass in our application by code. for examples, registration forms, user data, user profiles, and delete user data. Thus after Running our registered user Test code we need to make sure that whatever information we pass by Test code will get successfully saved into the Database as soon as user registered in our application.

2) Another use case of performing database testing with Selenium WebDriver by building mysql connection either with our localhost and either with another system IP.

Database Verification Using Selenium Webdriver

Below Code with mention all scenarios for User Register in Bookingcommerce.com

Below is my Excel sheet :

People Also Ask

Thus, Selenium WebDriver alone is ineligible to perform database testing but this can be done using Java Database Connectivity API (JDBC). The API lets the user connect and interact with the data source and fetch the data with the help of automated queries. To be able to exploit the JDBC API,.... Readmore ››
You can take data using excel or CSV file as well but some company still use the database to take data from the different database. As we already know, Selenium does not support Database Testing but partially we can do using JDBC and ODBC.. Readmore ››

Selenium Webdriver Api

As the world is evolving towards big data, database plays a major role in handling the records and maintaining the sequence of it. To ensure that there are no defects while processing the data, Database Testing is essential. In Automation Testing, Selenium is one such tool which helps in providing functionalities to test the database.. Readmore ››

Selenium Webdriver Firefox

In selenium scripts, when there is a need of getting the Data from the database we may have to use APIs which helps to interact with database like JDBC. Java Database Connectivity (JDBC) is a Java API which is used to connect and interact with Database.. Readmore ››