Since I put my script in to a test_ file and attempted to run it from a
run_all_tests script w/ class, etc. like the example in the unittests
directory, I get the following error, and I cannot figure out what the
problem is??:
>ruby all_cmg_tests.rb
Action: Open Internet Explorer and go to the test site:
https://qa2.ctdev.com:8082/
Action: Open file:
C:\ruby\lib\ruby\gems\1.8\gems\watir-1.5.1.1164\CMG_tests\Policy_Informa
tion.xls
Action: Enter superadmin in the 'username' text field
Action: Enter changeit in the 'password' text field
Action: Click the 'Log In' button
Action: Check that the 'Home' link appears on the page and return
true/false
Loaded suite all_cmg_tests
Started
Action: Go to windows sheet
Action: Verify default local values for device: windows
Action: Click default policies 'Menu Item'
E.
Finished in 0.031 seconds.
1) Error:
test_Policy_Drop_Down_Possible_Values(TC_Policies):
WIN32OLERuntimeError: unknown property or method `document'
HRESULT error code:0x80010108
The object invoked has disconnected from its clients.
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:1775:in
`method_missing'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:1775:in
`document'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:1157:in
`each_element'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:1166:in
`locate'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:1123:in
`locate_tagged_element'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:3201:in
`locate'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:2412:in
`assert_exists'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./watir.rb:3260:in
`[]'
./utilities.rb:97:in `clickMenuItem'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1164/./CMG_tests/policy_test.
rb:22:in `test_Policy_Drop_Down_Possible_Values'
2 tests, 0 assertions, 0 failures, 1 errors
>Exit code: 0
Here is my code(NOTE: everything works fine in it's own script)
policy_test:
#includes:
require 'rubygems'
gem 'watir'
require 'watir'
require 'pp'
require 'utilities'
require 'test/unit/testcase'
require 'win32ole'
require 'unittests/setup'
class TC_Policies < Test::Unit::TestCase
include Watir
def setup
#~ clickMenuItem($ie, "default policies")
end
def test_Policy_Drop_Down_Possible_Values()
sheet = selectPolicyExcelSheet('windows')
puts " Action: Verify default local values for device: " + 'windows'
clickMenuItem($ie, "default policies")
clickPolicyTab($ie, 'windows')
allPopulatedCells = sheet.Range('a2:a200').value# The data is in the
cell(s) listed
for i in 2..allPopulatedCells.length+1
#~ debugfor i in 2..2+1
currentCell = (i).to_s
indexCell = INDEX_COLUMN + currentCell
index = sheet.Range(indexCell).value.to_s #get value of single cell
controlTypeCell = CONTROL_TYPE_COLUMN + currentCell
controlType = sheet.Range(controlTypeCell).value.to_s #get value of
single cell
if index != "" and controlType == "drop down"
index = index.strip.sub(/\.0+$/,'')
policyCell = POLICY_NAME_COLUMN + (i).to_s
policyName = sheet.Range(policyCell).value.to_s #get value of
single cell
possibleValuesCell = POSSIBLE_VALUES_COLUMN + (i).to_s
expectedValue = sheet.Range(possibleValuesCell).value.to_s #get
value of single cell
expectedValue = expectedValue.strip.sub(/\.0+$/,'')
deviceName = convertToUIName('windows')# strip off junk
actualValue = $ie.select_list(:id, deviceName + '.' + index +
'.input_value').text.to_s
while actualValue.rindex("\r")
actualValue = actualValue.strip.sub(/\r/,'')
end
assert_equal( expectedValue, actualValue )
#~ if expectedValue == actualValue
#~ tc_Pass = true
#~ puts "PASS"
#~ else
#~ tc_Pass = false
#~ puts "FAIL"
#~ end
#~ puts 'Excel Row: ' + (i).to_s
#~ puts 'Policy Name: (' + 'deviceName' + ') ' + policyName
#~ puts ' Expected default value: ' + expectedValue.inspect
#~ puts ' Actual drop down value(s):' + actualValue.inspect
end
end
return tc_Pass
end
def test_new
end
end
########################################################################
###########################
all_cmg_tests:
require 'rubygems'
gem 'watir'
require 'utilities'
#~ require 'test/unit/testcase'
require 'test/unit'
require 'win32ole'
include Watir
require 'LoginSuperadmin'
require 'PolicyNoExtraPolicies'
require 'PolicyDropDownPossibleValues'
require 'PolicyDefaultLocalValues'
require 'PolicyToolTipValues'
TOPDIR = File.join(File.dirname(__FILE__), '..')
$LOAD_PATH.unshift TOPDIR
deviceList = ['windows',
'Pocket PC',
'Smartphone',
'Symbian',
'Blackberry'
]
#Excel File Column Constants
POLICY_NAME_COLUMN = 'a'
POSSIBLE_VALUES_COLUMN='b'
DEFAULT_VALUES_COLUMN = 'c'
TOOL_TIP_COLUMN = 'e'
INDEX_COLUMN = 'g'
CONTROL_TYPE_COLUMN = 'h'
cmgServerName = 'qa2'
openCMGServer(cmgServerName)
openPolicyExcelFile()
login("superadmin","changeit")
topdir = File.join(File.dirname(__FILE__), '..')
Dir.chdir topdir do
$all_tests = Dir["CMG_tests/*_test.rb"]
end
Dir.chdir TOPDIR
$all_tests.each {|x| require x}
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general