Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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.

share|improve this question

closed as unclear what you're asking by Kate Paulk, user246, dzieciou, corsiKa Jul 10 at 14:39

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

    
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 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 at 14:18
    
@corsiKa: Still you didn't get my question? then please let me know. –  QA4it Jul 15 at 14:48

1 Answer 1

up vote 1 down vote accepted

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
share|improve this answer
    
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 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. –  PaulDonny Jul 2 at 14:16
    
Thanks a lot, could you please let me know the sample (Application and DB) to verify, if possible or any links may help for me. –  QA4it Jul 2 at 14:34
    
Updated the answer to reflect the question –  PaulDonny Jul 2 at 17:15

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