I'm a beginner when it comes to programming so I have a problem now...
I've used an example I found on a watir page called Example Logging
(pasted at the end of this message). It runs two tests,
test_a_simplesearch and test_b_googlenews, and also logs the results
with a file called example_logger1. What I would like to do now is to
put the two tests in a separate file for each of them and then load/
require them from, what I call, the run file. How do I do that?
/Mari
require 'watir'
require 'test/unit'
$LOAD_PATH << File.dirname(__FILE__)
require 'example_logger1'
class TC_google_logging < Test::Unit::TestCase
def start
#open the IE browser
$ie = Watir::IE.new
filePrefix = "test_logger1"
#create a logger
$logger = LoggerFactory.start_xml_logger(filePrefix)
$ie.set_logger($logger)
end
def test_a_simplesearch
#call start method...
start #fires up the IE browser and a logger object
#variables
test_site = 'http://www.google.com'
$logger.log("")
$logger.log("## Beginning of test: Google search") #logs only to
corelogger file
$logger.log("Step 1: Go to the Google site: www.google.com")
$ie.goto(test_site)
$logger.log(" Action: entered " + test_site + " in the address
bar.")
$logger.log("Step 2: Enter 'pickaxe' in the search text field")
$ie.text_field(:name, "q").set("pickaxe")
$logger.log("Step 3: Click the 'Google Search' button")
$ie.button(:name, "btnG").click
if $ie.text.include?("Programming Ruby")
$logger.log("Passed. Found test string 'Programming Ruby' ")
$logger.log_results("test_a_simplesearch", "pickaxe",
"Programming Ruby", "TEST PASSED.") #logs to both the XML file and
corelogger
else
$logger.log("*FAILED*.")
$logger.log_results("test_a_simplesearch", "pickaxe",
"Programming Ruby", "TEST FAILED.") #logs to both the XML file and
corelogger
end
$logger.log "## End of test: google search\n"
end #end of test_simplesearch
def test_b_googlenews
#variables
test_site = 'http://news.google.com'
$logger.log("## Beginning of test: Google News")
$logger.log("Step 1: go to the Google news site: news.google.com")
$ie.goto(test_site)
$logger.log(" Action: entered " + test_site + " in the address
bar.")
$logger.log("Step 2: Select Canada from the Top Stories drop-down
list")
$ie.select_list( :index , 1).select("Canada English")
$logger.log("Step 3: click the 'Go' button")
$ie.button(:caption, "Go").click
if $ie.text.include?("Canada")
$logger.log("TEST PASSED. Found test string 'Canada' ")
$logger.log_results("test_b_googlenews", "Canada English",
"Canada", "TEST PASSED.") #logs to both the XML file and corelogger
else
$logger.log("TEST FAILED.")
$logger.log_results("test_b_googlenews", "Canada English",
"Canada", "TEST FAILED.") #logs to both the XML file and
corelogger
end
$logger.log '## End of test: Google news selection'
$logger.end_log #close XML log file
end #end of test_googlenews
end #end of class TC_google_logging
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines:
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---