3

I want to validate application output result with Database using selenium webdriver (Java). Please let me know how this can be achieved.

Or could you please let me know how to use selenium webdriver with database?.

I am able to connect to database by below code. Code to connect to database:

import java.sql.*; 
public class Db1 { 
static final String JDBC_DRIVER = "org.gjt.mm.mysql.Driver"; 
static final String DB_URL="jdbc:mysql://111.0.0.1:12345/actitime";
static final String USER ="actitime"; 
static final String PASS ="actitime1";
 public static void main(String[]args){ 
Connection conn=null;Statement stmt=null; 
try{
Class.forName("com.mysql.jdbc.Driver"); 
conn=DriverManager.getConnection(DB_URL, USER, PASS); 
System.out.println("Connected database successfully"); 
System.out.println("Creating statement");
stmt=conn.createStatement();
.....
.....

But not not sure how to validate result of the application using selenium webdriver and result saved in the database.

3
  • I'm quite sure it is possible to validate results based on database values. But whether or not you should be validating is such an open ended question, I'm not sure we can really answer you. If you could refine this question, distilling it into what specific problems you're trying to solve, we would have an easier time diagnosing and helping to solve them. Thanks!
    – corsiKa
    Jul 10, 2014 at 14:42
  • @corsiKa Updated the question with code. And I wanted to know how to validate application (Front end) result with backend (Data base) result using selenium webdriver?. Please let me know how to verify this?.
    – QA4it
    Jul 15, 2014 at 14:18
  • @corsiKa: Still you didn't get my question? then please let me know.
    – QA4it
    Jul 15, 2014 at 14:48

1 Answer 1

1

It sounds like the majority of your issue is in creating the connection to your Database. However, you lack to mention the type of database so I will try and cover some of the more popular ones.

Oracle Tutorial or SO Question

SQL Server JTDS

I could list all of the types of databases for years so here is a list of database related tutorials.

If you need more specific help than please ask a more specific question.

From the comments:

  1. Obtain the data from the Application that will need to be validated against the database
  2. Obtain the data from the database
  3. Compare the results
2
  • We have java and .net applications and client requested us to cross check with DB (In selenium script only) so I need to work on Mysql, oracle DB. Moral Story: Once if you run your selenium script it should verify the functionality and connect to DB and verify the result. Whether this is possible FRIEND?.
    – QA4it
    Jul 2, 2014 at 14:09
  • 1
    Yes, you can. Your selenium scripts are built into a Java program that can use any Java code you feel you need in order to achieve your test results. Just create functions and assertions that utilize database calls instead of selenium for those checks.
    – Paul Muir
    Jul 2, 2014 at 14:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.