P. 1
Selenium Documentation

Selenium Documentation

|Views: 848|Likes:
Publicado porDivyesh Dave

More info:

Published by: Divyesh Dave on Mar 16, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

04/21/2011

pdf

text

original

Note: This section is not yet developed.

7.10.1 Error Reporting

7.10.2 Recovering From Failure

A quick note though–recognize that your programming language’s exception- handling support can be
used for error handling and recovery.

This section has not been developed yet.

7.10.3 Database Validations

Since you can also do database queries from your favorite programming language, assuming you have
database support functions, why not use them for some data validations/retrieval on the Application
Under Test?

Consider the example of a registration process where a registered email address is to be retrieved from
the database. An example of establishing a DB connection and retrieving data from the DB would be:

In Java:

// Load Microsoft SQL Server JDBC driver.
Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" );

// Prepare connection url.
String url = "jdbc:sqlserver://192.168.1.180:1433;DatabaseName=TEST_DB" ;

// Get connection to DB.
public static Connection con =
DriverManager.getConnection(url, "username" , "password" );

112

Chapter 7. Test Design Considerations

Selenium Documentation, Release 1.0

// Create statement object which would be used in writing DDL and DML
// SQL statement.
public static Statement stmt = con.createStatement();

// Send SQL SELECT statements to the database via the Statement.executeQuery
// method which returns the requested information as rows of data in a
// ResultSet object.

ResultSet result = stmt.executeQuery
( "select top 1 email_address from user_register_table" );

// Fetch value of "email_address" from "result" object.
String emailaddress = result.getString( "email_address" );

// Use the fetched value to login to application.
selenium.type( "userID" , emailaddress);

This is a very simple example of data retrieval from a DB in Java. A more complex test could be to
validate that inactive users are not able to login to the application. This wouldn’t take too much work
from what you’ve already seen.

7.10. Handling Errors

113

Selenium Documentation, Release 1.0

114

Chapter 7. Test Design Considerations

CHAPTER

EIGHT

You're Reading a Free Preview

Descarga
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->