reading test data from external sources

9 views
Skip to first unread message

chimeara

unread,
Nov 2, 2009, 7:27:41 AM11/2/09
to iTest2
is it possible to use a database table or an excel spreadsheet as a
source for test data, ie if I want to run a logon test script many
times using different user ids to test access rights?

Zhimin

unread,
Nov 2, 2009, 7:47:14 AM11/2/09
to iTest2
> is it possible to use a database table or an excel spreadsheet as a source for test data,

Yes. This is going to topic of next blog article!

You can try the example in v1.6.6 (released today),

Open demo project C:\Program Files\iTest2\samples\demo\demo.tpr
Select file database_spec.rb
The Excel file: C:\Program Files\iTest2\samples\demo\testdata
\users.xls (contains 3 username-password combinations)

The sample script tries login site: travel.agileway.net with 3 pairs
of username/passwords and do assertion accordingly.

Test Scripts as below:

spec "Use Excel for data driven web tests" do
include RWebSpec::RSpecHelper

before(:all) do
open_browser("http://travel.agileway.net")

# Load Excel file
excel_file = File.join(File.dirname(__FILE__), "testdata",
"users.xls")
excel_book = Spreadsheet.open excel_file
@excel_sheet1 = excel_book.worksheet "Users" # or use 0 for first
sheet
end

scenario "Load user list from an Excel spreadsheet to test multiple
user logins" do
# Iterate each row in the spreadsheet, use data for test scripts
@excel_sheet1.each_with_index do |row, idx|
next if idx == 0 # ignore first row
login, password, expected_text = row[1], row[2], row[3]
goto_page("/")
enter_text("userName", login)
enter_text("password", password)
click_button("Sign In")
page_text.should include(expected_text)
failsafe{ click_link("SIGN-OFF") } # if logged in OK, try log
out
end
end

end


Regards,
Zhimin


On Nov 2, 10:27 pm, chimeara <gordon.leibbra...@ilabquality.com>
wrote:

Gordon Leibbrandt

unread,
Nov 2, 2009, 8:00:35 AM11/2/09
to ite...@googlegroups.com
many thanks for your prompt response Zhimin

Regards
 
Gordon Leibbrandt  |  Director: Global Operations  |  iLAB (Pty) Ltd

Cell: +27 (82) 600 8313  |  Tel: +27 (11) 807-2308  |  Fax (international):
+2711807 7916 ; Fax (local) 086 679 8916  |  email:
gordon.l...@ilabquality.com  |  http://www.ilabquality.com



The contents and any attachments to this e-mail are subject to the following
disclaimer:  www.ilabquality.com/disclaimer
Reply all
Reply to author
Forward
0 new messages