firewatir 1.2.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. data/lib/firewatir.rb +50 -0
  2. data/lib/firewatir/MozillaBaseElement.rb +1863 -0
  3. data/lib/firewatir/container.rb +534 -0
  4. data/lib/firewatir/exceptions.rb +10 -0
  5. data/lib/firewatir/firefox.rb +1127 -0
  6. data/lib/firewatir/htmlelements.rb +1911 -0
  7. data/lib/firewatir/version.rb +5 -0
  8. data/{firewatir → lib/firewatir}/winClicker.rb +0 -0
  9. data/{firewatir → lib/firewatir}/x11.rb +0 -0
  10. data/unittests/attach_to_new_window_test.rb +20 -12
  11. data/unittests/bug_fixes_test.rb +79 -69
  12. data/unittests/buttons_xpath_test.rb +45 -44
  13. data/unittests/checkbox_test.rb +86 -85
  14. data/unittests/checkbox_xpath_test.rb +58 -58
  15. data/unittests/div_test.rb +117 -115
  16. data/unittests/filefield_test.rb +12 -12
  17. data/unittests/filefield_xpath_test.rb +11 -11
  18. data/unittests/form_test.rb +134 -133
  19. data/unittests/frame_test.rb +42 -41
  20. data/unittests/hidden_test.rb +40 -40
  21. data/unittests/hidden_xpath_test.rb +32 -32
  22. data/unittests/images_test.rb +85 -84
  23. data/unittests/images_xpath_test.rb +57 -56
  24. data/unittests/iostring_test.rb +1 -1
  25. data/unittests/javascript_test.rb +42 -38
  26. data/unittests/links_test.rb +88 -86
  27. data/unittests/links_xpath_test.rb +38 -38
  28. data/unittests/mozilla_all_tests.rb +2 -14
  29. data/unittests/pre_test.rb +27 -25
  30. data/unittests/radios_test.rb +86 -86
  31. data/unittests/radios_xpath_test.rb +48 -48
  32. data/unittests/redirect_test.rb +20 -19
  33. data/unittests/selectbox_test.rb +72 -71
  34. data/unittests/selectbox_xpath_test.rb +58 -56
  35. data/unittests/setup.rb +22 -27
  36. data/unittests/table_test.rb +89 -88
  37. data/unittests/table_xpath_test.rb +37 -36
  38. data/unittests/textfields_test.rb +105 -102
  39. data/unittests/textfields_xpath_test.rb +53 -52
  40. metadata +37 -18
  41. data/MozillaBaseElement.rb +0 -1780
  42. data/container.rb +0 -900
  43. data/firewatir.rb +0 -1195
  44. data/firewatir/exceptions.rb +0 -44
  45. data/firewatir/testUnitAddons.rb +0 -8
  46. data/htmlelements.rb +0 -2281
  47. data/unittests/buttons_test.rb +0 -215
@@ -1,100 +1,100 @@
1
1
  # feature tests for Radio Buttons
2
2
  # revision: $Revision: 1.0 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_Radios_XPath < Test::Unit::TestCase
8
- include FireWatir
8
+
9
9
 
10
10
  def setup()
11
- $ff.goto($htmlRoot + "radioButtons1.html")
11
+ goto_page("radioButtons1.html")
12
12
  end
13
13
 
14
14
  def test_Radio_Exists
15
- assert($ff.radio(:xpath, "//input[@name='box1']").exists?)
16
- assert($ff.radio(:xpath, "//input[@id='box5']").exists?)
15
+ assert(browser.radio(:xpath, "//input[@name='box1']").exists?)
16
+ assert(browser.radio(:xpath, "//input[@id='box5']").exists?)
17
17
 
18
- assert_false($ff.radio(:xpath, "//input[@name='missingname']").exists?)
19
- assert_false($ff.radio(:xpath, "//input[@id='missingid']").exists?)
18
+ assert_false(browser.radio(:xpath, "//input[@name='missingname']").exists?)
19
+ assert_false(browser.radio(:xpath, "//input[@id='missingid']").exists?)
20
20
  end
21
21
 
22
22
  def test_Radio_Enabled
23
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='noName']").enabled? }
24
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@id='noName']").enabled? }
25
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='box4' and @value='6']").enabled? }
23
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").enabled? }
24
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@id='noName']").enabled? }
25
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='box4' and @value='6']").enabled? }
26
26
 
27
- assert_false($ff.radio(:xpath, "//input[@name='box2']").enabled?)
28
- assert($ff.radio(:xpath, "//input[@id='box5']").enabled?)
29
- assert($ff.radio(:xpath, "//input[@name='box1']").enabled?)
27
+ assert_false(browser.radio(:xpath, "//input[@name='box2']").enabled?)
28
+ assert(browser.radio(:xpath, "//input[@id='box5']").enabled?)
29
+ assert(browser.radio(:xpath, "//input[@name='box1']").enabled?)
30
30
  end
31
31
 
32
32
  def test_little
33
- assert_false($ff.button(:xpath,"//input[@name='foo']").enabled?)
33
+ assert_false(browser.button(:xpath,"//input[@name='foo']").enabled?)
34
34
  end
35
35
 
36
36
  def test_onClick
37
- assert_false($ff.button(:xpath,"//input[@name='foo']").enabled?)
38
- $ff.radio(:xpath, "//input[@name='box5' and @value='1']").set
39
- assert($ff.button(:xpath,"//input[@name='foo']").enabled?)
37
+ assert_false(browser.button(:xpath,"//input[@name='foo']").enabled?)
38
+ browser.radio(:xpath, "//input[@name='box5' and @value='1']").set
39
+ assert(browser.button(:xpath,"//input[@name='foo']").enabled?)
40
40
 
41
- $ff.radio(:xpath, "//input[@name='box5' and @value='2']").set
42
- assert_false($ff.button(:xpath,"//input[@name='foo']").enabled?)
41
+ browser.radio(:xpath, "//input[@name='box5' and @value='2']").set
42
+ assert_false(browser.button(:xpath,"//input[@name='foo']").enabled?)
43
43
  end
44
44
 
45
45
  def test_Radio_isSet
46
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='noName']").isSet? }
46
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").isSet? }
47
47
 
48
- puts "radio 1 is set : #{ $ff.radio(:xpath, "//input[@name='box1']").isSet? } "
49
- assert_false($ff.radio(:xpath, "//input[@name='box1']").isSet?)
48
+ puts "radio 1 is set : #{ browser.radio(:xpath, "//input[@name='box1']").isSet? } "
49
+ assert_false(browser.radio(:xpath, "//input[@name='box1']").isSet?)
50
50
 
51
- assert($ff.radio(:xpath, "//input[@name='box3']").isSet?)
52
- assert_false($ff.radio(:xpath, "//input[@name='box2']").isSet?)
51
+ assert(browser.radio(:xpath, "//input[@name='box3']").isSet?)
52
+ assert_false(browser.radio(:xpath, "//input[@name='box2']").isSet?)
53
53
 
54
- assert( $ff.radio(:xpath, "//input[@name='box4' and @value='1']").isSet?)
55
- assert_false($ff.radio(:xpath, "//input[@name='box4' and @value='2']").isSet?)
54
+ assert( browser.radio(:xpath, "//input[@name='box4' and @value='1']").isSet?)
55
+ assert_false(browser.radio(:xpath, "//input[@name='box4' and @value='2']").isSet?)
56
56
  end
57
57
 
58
58
  def test_radio_clear
59
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='noName']").clear }
59
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").clear }
60
60
 
61
- $ff.radio(:xpath, "//input[@name='box1']").clear
62
- assert_false($ff.radio(:xpath, "//input[@name='box1']").isSet?)
61
+ browser.radio(:xpath, "//input[@name='box1']").clear
62
+ assert_false(browser.radio(:xpath, "//input[@name='box1']").isSet?)
63
63
 
64
- assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='box2']").clear }
65
- assert_false($ff.radio(:xpath, "//input[@name='box2']").isSet?)
64
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:xpath, "//input[@name='box2']").clear }
65
+ assert_false(browser.radio(:xpath, "//input[@name='box2']").isSet?)
66
66
 
67
- $ff.radio(:xpath, "//input[@name='box3']").clear
68
- assert_false($ff.radio(:xpath, "//input[@name='box3']").isSet?)
67
+ browser.radio(:xpath, "//input[@name='box3']").clear
68
+ assert_false(browser.radio(:xpath, "//input[@name='box3']").isSet?)
69
69
 
70
- $ff.radio(:xpath, "//input[@name='box4' and @value='1']").clear
71
- assert_false($ff.radio(:xpath, "//input[@name='box4' and @value='1']").isSet?)
70
+ browser.radio(:xpath, "//input[@name='box4' and @value='1']").clear
71
+ assert_false(browser.radio(:xpath, "//input[@name='box4' and @value='1']").isSet?)
72
72
  end
73
73
 
74
74
  def test_radio_getState
75
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='noName']").getState }
75
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").getState }
76
76
 
77
- assert_equal( false , $ff.radio(:xpath, "//input[@name='box1']").getState )
78
- assert_equal( true , $ff.radio(:xpath, "//input[@name='box3']").getState)
77
+ assert_equal( false , browser.radio(:xpath, "//input[@name='box1']").getState )
78
+ assert_equal( true , browser.radio(:xpath, "//input[@name='box3']").getState)
79
79
 
80
80
  # radioes that have the same name but different values
81
- assert_equal( false , $ff.radio(:xpath, "//input[@name='box4' and @value='2']").getState )
82
- assert_equal( true , $ff.radio(:xpath, "//input[@name='box4' and @value='1']").getState)
81
+ assert_equal( false , browser.radio(:xpath, "//input[@name='box4' and @value='2']").getState )
82
+ assert_equal( true , browser.radio(:xpath, "//input[@name='box4' and @value='1']").getState)
83
83
  end
84
84
 
85
85
  def test_radio_set
86
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='noName']").set }
87
- $ff.radio(:xpath, "//input[@name='box1']").set
88
- assert($ff.radio(:xpath, "//input[@name='box1']").isSet?)
86
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").set }
87
+ browser.radio(:xpath, "//input[@name='box1']").set
88
+ assert(browser.radio(:xpath, "//input[@name='box1']").isSet?)
89
89
 
90
- assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='box2']").set }
90
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:xpath, "//input[@name='box2']").set }
91
91
 
92
- $ff.radio(:xpath, "//input[@name='box3']").set
93
- assert($ff.radio(:xpath, "//input[@name='box3']").isSet?)
92
+ browser.radio(:xpath, "//input[@name='box3']").set
93
+ assert(browser.radio(:xpath, "//input[@name='box3']").isSet?)
94
94
 
95
95
  # radioes that have the same name but different values
96
- $ff.radio(:xpath, "//input[@name='box4' and @value='3']").set
97
- assert($ff.radio(:xpath, "//input[@name='box4' and @value='3']").isSet?)
96
+ browser.radio(:xpath, "//input[@name='box4' and @value='3']").set
97
+ assert(browser.radio(:xpath, "//input[@name='box4' and @value='3']").isSet?)
98
98
  end
99
99
 
100
100
  end
@@ -1,40 +1,41 @@
1
1
  # feature tests for Javascript redirect
2
2
  # revision: $Revision: 1.0 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_Redirect < Test::Unit::TestCase
8
- include FireWatir
9
-
8
+
10
9
  def setup
11
- $ff.goto($htmlRoot + "redirect.html")
10
+ goto_page("redirect.html")
12
11
  end
13
12
 
14
13
  def goto_multiple_redirect
15
- $ff.goto($htmlRoot + "redirect1.html")
14
+ goto_page("redirect1.html")
16
15
  end
17
16
 
17
+ tag_method :test_single_redirect, :fails_on_ie
18
18
  def test_single_redirect
19
- assert_raises(UnknownObjectException) {$ff.div(:id , "div77").click }
20
- assert_raises(UnknownObjectException) {$ff.div(:title , "div77").click }
19
+ assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
20
+ assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
21
21
 
22
- assert($ff.text_field(:name, "text1").verify_contains("0") )
23
- $ff.div(:id , "div3").click
24
- assert($ff.text_field(:name, "text1").verify_contains("1") )
25
- $ff.div(:id , "div4").click
26
- assert($ff.text_field(:name, "text1").verify_contains("0") )
22
+ assert(browser.text_field(:name, "text1").verify_contains("0") )
23
+ browser.div(:id , "div3").click
24
+ assert(browser.text_field(:name, "text1").verify_contains("1") )
25
+ browser.div(:id , "div4").click
26
+ assert(browser.text_field(:name, "text1").verify_contains("0") )
27
27
  end
28
28
 
29
+ tag_method :test_multiple_redirect, :fails_on_ie
29
30
  def test_multiple_redirect
30
31
  goto_multiple_redirect()
31
- assert_raises(UnknownObjectException) {$ff.div(:id , "div77").click }
32
- assert_raises(UnknownObjectException) {$ff.div(:title , "div77").click }
32
+ assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
33
+ assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
33
34
 
34
- assert($ff.text_field(:name, "text1").verify_contains("0") )
35
- $ff.div(:id , "div3").click
36
- assert($ff.text_field(:name, "text1").verify_contains("1") )
37
- $ff.div(:id , "div4").click
38
- assert($ff.text_field(:name, "text1").verify_contains("0") )
35
+ assert(browser.text_field(:name, "text1").verify_contains("0") )
36
+ browser.div(:id , "div3").click
37
+ assert(browser.text_field(:name, "text1").verify_contains("1") )
38
+ browser.div(:id , "div4").click
39
+ assert(browser.text_field(:name, "text1").verify_contains("0") )
39
40
  end
40
41
  end
@@ -1,141 +1,142 @@
1
1
  # feature tests for Select Boxes
2
2
  # revision: $Revision: 1.0 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_SelectList < Test::Unit::TestCase
8
- include FireWatir
8
+
9
9
 
10
10
  def setup()
11
- $ff.goto($htmlRoot + "selectboxes1.html")
11
+ goto_page("selectboxes1.html")
12
12
  end
13
13
 
14
14
  def test_textBox_Exists
15
- assert($ff.select_list(:name, "sel1").exists?)
16
- assert_false($ff.select_list(:name, "missing").exists?)
17
- assert_false($ff.select_list(:id, "missing").exists?)
15
+ assert(browser.select_list(:name, "sel1").exists?)
16
+ assert_false(browser.select_list(:name, "missing").exists?)
17
+ assert_false(browser.select_list(:id, "missing").exists?)
18
18
  end
19
19
 
20
20
  def test_select_list_enabled
21
- assert($ff.select_list(:name, "sel1").enabled?)
22
- assert_raises(UnknownObjectException) { $ff.select_list(:name, "NoName").enabled? }
21
+ assert(browser.select_list(:name, "sel1").enabled?)
22
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").enabled? }
23
23
  end
24
24
 
25
25
  def test_select_list_getAllContents
26
- assert_raises(UnknownObjectException) { $ff.select_list(:name, "NoName").getAllContents }
26
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").getAllContents }
27
27
  assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
28
- $ff.select_list(:name, "sel1").getAllContents)
28
+ browser.select_list(:name, "sel1").getAllContents)
29
29
  end
30
30
 
31
31
  def test_Option_text_select
32
- assert_raises(UnknownObjectException) { $ff.select_list(:name, "sel1").option(:text, "missing item").select }
33
- assert_raises(UnknownObjectException) { $ff.select_list(:name, "sel1").option(:text, /missing/).select }
34
- assert_raises(MissingWayOfFindingObjectException) { $ff.select_list(:name, "sel1").option(:missing, "Option 1").select }
32
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").select }
33
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, /missing/).select }
34
+ assert_raises(MissingWayOfFindingObjectException) { browser.select_list(:name, "sel1").option(:missing, "Option 1").select }
35
35
 
36
36
  # the select method keeps any currently selected items - use the clear selection method first
37
- $ff.select_list( :name , "sel1").clearSelection
38
- $ff.select_list( :name , "sel1").option(:text, "Option 1").select
39
- assert_equal( ["Option 1" ] , $ff.select_list(:name, "sel1").getSelectedItems)
37
+ browser.select_list( :name , "sel1").clearSelection
38
+ browser.select_list( :name , "sel1").option(:text, "Option 1").select
39
+ assert_equal( ["Option 1" ] , browser.select_list(:name, "sel1").getSelectedItems)
40
40
  end
41
41
 
42
42
 
43
+ tag_method :test_option_class_name, :fails_on_ie
43
44
  def test_option_class_name
44
45
 
45
46
  # the option object doesnt inherit from element, so this doesnt work
46
- assert_raises(UnknownObjectException) { $ff.select_list(:name, "sel1").option(:text, "missing item").class_name }
47
- assert_equal("option_style" , $ff.select_list(:name, "sel2").option(:value , 'o2').class_name)
48
- assert_equal("" , $ff.select_list(:name, "sel2").option(:value , 'o1').class_name)
47
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").class_name }
48
+ assert_equal("option_style" , browser.select_list(:name, "sel2").option(:value , 'o2').class_name)
49
+ assert_equal("" , browser.select_list(:name, "sel2").option(:value , 'o1').class_name)
49
50
 
50
51
  end
51
52
 
52
53
  def test_selectBox_select_using_value
53
- assert_raises(UnknownObjectException) { $ff.select_list(:name, "NoName").getSelectedItems }
54
- assert_raises(NoValueFoundException) { $ff.select_list(:name, "sel1").select_value("missing item") }
55
- assert_raises(NoValueFoundException) { $ff.select_list(:name, "sel1").select_value(/missing/) }
54
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").getSelectedItems }
55
+ assert_raises(NoValueFoundException) { browser.select_list(:name, "sel1").select_value("missing item") }
56
+ assert_raises(NoValueFoundException) { browser.select_list(:name, "sel1").select_value(/missing/) }
56
57
 
57
58
  # the select method keeps any currently selected items - use the clear selectcion method first
58
- $ff.select_list( :name , "sel1").clearSelection
59
- $ff.select_list( :name , "sel1").select_value("o1")
60
- assert_equal( ["Option 1" ] , $ff.select_list(:name, "sel1").getSelectedItems)
59
+ browser.select_list( :name , "sel1").clearSelection
60
+ browser.select_list( :name , "sel1").select_value("o1")
61
+ assert_equal( ["Option 1" ] , browser.select_list(:name, "sel1").getSelectedItems)
61
62
 
62
- $ff.select_list( :name , "sel1").clearSelection
63
- $ff.select_list( :name , "sel1").select_value(/2/)
64
- assert_equal( ["Option 2" ] , $ff.select_list(:name, "sel1").getSelectedItems)
63
+ browser.select_list( :name , "sel1").clearSelection
64
+ browser.select_list( :name , "sel1").select_value(/2/)
65
+ assert_equal( ["Option 2" ] , browser.select_list(:name, "sel1").getSelectedItems)
65
66
 
66
- $ff.select_list( :name , "sel2").clearSelection
67
- $ff.select_list( :name , "sel2").select_value(/4/)
68
- $ff.select_list( :name , "sel2").select_value(/2/)
67
+ browser.select_list( :name , "sel2").clearSelection
68
+ browser.select_list( :name , "sel2").select_value(/4/)
69
+ browser.select_list( :name , "sel2").select_value(/2/)
69
70
  assert_equal( ["Option 2" , "Option 4" ] ,
70
- $ff.select_list(:name, "sel2").getSelectedItems)
71
+ browser.select_list(:name, "sel2").getSelectedItems)
71
72
 
72
73
  # these are to test the onchange event
73
74
  # the event shouldnt get fired, as this is the selected item
74
- $ff.select_list( :name , "sel3").select_value( /3/ )
75
- assert_false($ff.text.include?("Pass") )
75
+ browser.select_list( :name , "sel3").select_value( /3/ )
76
+ assert_false(browser.text.include?("Pass") )
76
77
  end
77
78
 
78
79
  def test_select_list_select_using_value2
79
80
  # the event should get fired
80
- $ff.select_list( :name , "sel3").select_value( /2/ )
81
- assert($ff.text.include?("PASS") )
81
+ browser.select_list( :name , "sel3").select_value( /2/ )
82
+ assert(browser.text.include?("PASS") )
82
83
  end
83
84
 
84
85
  def test_select_list_properties
85
- assert_raises(UnknownObjectException) { $ff.select_list(:index, 199).value }
86
- assert_raises(UnknownObjectException) { $ff.select_list(:index, 199).name }
87
- assert_raises(UnknownObjectException) { $ff.select_list(:index, 199).id }
88
- assert_raises(UnknownObjectException) { $ff.select_list(:index, 199).disabled }
89
- assert_raises(UnknownObjectException) { $ff.select_list(:index, 199).type }
86
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).value }
87
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).name }
88
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).id }
89
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).disabled }
90
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).type }
90
91
 
91
- assert_equal("o3" , $ff.select_list(:index, 1).value)
92
- assert_equal("sel1" , $ff.select_list(:index, 1).name )
93
- assert_equal("" , $ff.select_list(:index, 1).id )
94
- assert_equal("select-one", $ff.select_list(:index, 1).type )
95
- assert_equal("select-multiple", $ff.select_list(:index, 2).type )
92
+ assert_equal("o3" , browser.select_list(:index, 1).value)
93
+ assert_equal("sel1" , browser.select_list(:index, 1).name )
94
+ assert_equal("" , browser.select_list(:index, 1).id )
95
+ assert_equal("select-one", browser.select_list(:index, 1).type )
96
+ assert_equal("select-multiple", browser.select_list(:index, 2).type )
96
97
 
97
- $ff.select_list(:index,1).select(/1/)
98
- assert_equal("o1" , $ff.select_list(:index, 1).value)
98
+ browser.select_list(:index,1).select(/1/)
99
+ assert_equal("o1" , browser.select_list(:index, 1).value)
99
100
 
100
- assert_false( $ff.select_list(:index, 1).disabled )
101
- assert( $ff.select_list(:index, 4).disabled )
102
- assert( $ff.select_list(:id, 'selectbox_4').disabled )
101
+ assert_false( browser.select_list(:index, 1).disabled )
102
+ assert( browser.select_list(:index, 4).disabled )
103
+ assert( browser.select_list(:id, 'selectbox_4').disabled )
103
104
  end
104
105
 
105
106
  def test_select_list_iterator
106
- assert_equal(5, $ff.select_lists.length)
107
- assert_equal("o3" , $ff.select_lists[1].value)
108
- assert_equal("sel1" , $ff.select_lists[1].name )
109
- assert_equal("select-one", $ff.select_lists[1].type )
110
- assert_equal("select-multiple" , $ff.select_lists[2].type )
107
+ assert_equal(5, browser.select_lists.length)
108
+ assert_equal("o3" , browser.select_lists[1].value)
109
+ assert_equal("sel1" , browser.select_lists[1].name )
110
+ assert_equal("select-one", browser.select_lists[1].type )
111
+ assert_equal("select-multiple" , browser.select_lists[2].type )
111
112
 
112
113
  index=1
113
- $ff.select_lists.each do |l|
114
- assert_equal( $ff.select_list(:index, index).name , l.name )
115
- assert_equal( $ff.select_list(:index, index).id , l.id )
116
- assert_equal( $ff.select_list(:index, index).type , l.type )
117
- assert_equal( $ff.select_list(:index, index).value , l.value )
114
+ browser.select_lists.each do |l|
115
+ assert_equal( browser.select_list(:index, index).name , l.name )
116
+ assert_equal( browser.select_list(:index, index).id , l.id )
117
+ assert_equal( browser.select_list(:index, index).type , l.type )
118
+ assert_equal( browser.select_list(:index, index).value , l.value )
118
119
  index+=1
119
120
  end
120
- assert_equal( index-1, $ff.select_lists.length)
121
+ assert_equal( index-1, browser.select_lists.length)
121
122
  # Bug Fix 25
122
- $ff.select_lists.each { |list| puts list.getAllContents() }
123
+ browser.select_lists.each { |list| puts list.getAllContents() }
123
124
  end
124
125
  end
125
126
 
126
127
  class TC_Select_Options < Test::Unit::TestCase
127
- include FireWatir
128
-
128
+ tags :fails_on_ie
129
+
129
130
  def setup()
130
- $ff.goto($htmlRoot + "select_tealeaf.html")
131
+ goto_page("select_tealeaf.html")
131
132
  end
132
133
 
133
134
  def test_options_text
134
- $ff.select_list(:name, 'op_numhits').option(:text, '>=').select
135
- assert($ff.select_list(:name, 'op_numhits').option(:text, '>=').selected)
136
- assert_equal( [">=" ] , $ff.select_list(:name, "op_numhits").getSelectedItems)
137
- assert_equal( "=" , $ff.select_list(:name, "op_numhits")[1].text)
138
- assert_equal( "0" , $ff.select_list(:name, "op_numhits")[1].value)
135
+ browser.select_list(:name, 'op_numhits').option(:text, '>=').select
136
+ assert(browser.select_list(:name, 'op_numhits').option(:text, '>=').selected)
137
+ assert_equal( [">=" ] , browser.select_list(:name, "op_numhits").getSelectedItems)
138
+ assert_equal( "=" , browser.select_list(:name, "op_numhits")[1].text)
139
+ assert_equal( "0" , browser.select_list(:name, "op_numhits")[1].value)
139
140
  end
140
141
  end
141
142
 
@@ -1,127 +1,129 @@
1
1
  # feature tests for Select Boxes
2
2
  # revision: $Revision: 1.0 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_Selectbox_XPath < Test::Unit::TestCase
8
- include FireWatir
8
+
9
9
 
10
10
  def setup()
11
- $ff.goto($htmlRoot + "selectboxes1.html")
11
+ goto_page("selectboxes1.html")
12
12
  end
13
13
 
14
14
  def test_textBox_Exists
15
- assert($ff.select_list(:xpath, "//select[@name='sel1']").exists?)
16
- assert_false($ff.select_list(:xpath, "//select[@name='missing']").exists?)
17
- assert_false($ff.select_list(:xpath, "//select[@id='missing']").exists?)
15
+ assert(browser.select_list(:xpath, "//select[@name='sel1']").exists?)
16
+ assert_false(browser.select_list(:xpath, "//select[@name='missing']").exists?)
17
+ assert_false(browser.select_list(:xpath, "//select[@id='missing']").exists?)
18
18
  end
19
19
 
20
+ tag_method :test_element_by_xpath_class, :fails_on_ie
20
21
  def test_element_by_xpath_class
21
- element = $ff.element_by_xpath("//select[@name='sel1']")
22
- assert(element.instance_of?(SelectList),"element class should be #{SelectList}; got #{element.class}")
22
+ element = browser.element_by_xpath("//select[@name='sel1']")
23
+ assert_class(element, 'SelectList')
23
24
  # FIXME got HTMLAnchorElement, should've gotten HTMLSelectElement
24
25
  # TODO: If element is not present, this should return null
25
- #element = $ff.element_by_xpath("//select[@name='missing']")
26
+ #element = browser.element_by_xpath("//select[@name='missing']")
26
27
  #assert(element.instance_of?(SelectList),"element class should be #{SelectList}; got #{element.class}")
27
28
  # FIXME got HTMLAnchorElement, should've gotten HTMLSelectElement
28
29
  # TODO: If element is not present, this should return null
29
- #element = $ff.element_by_xpath("//select[@id='missing']")
30
+ #element = browser.element_by_xpath("//select[@id='missing']")
30
31
  #assert(element.instance_of?(SelectList),"element class should be #{SelectList}; got #{element.class}")
31
32
  end
32
33
 
33
34
  def test_select_list_enabled
34
- assert($ff.select_list(:xpath, "//select[@name='sel1']").enabled?)
35
- assert_raises(UnknownObjectException) { $ff.select_list(:xpath, "//select[@name='NoName']").enabled? }
35
+ assert(browser.select_list(:xpath, "//select[@name='sel1']").enabled?)
36
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").enabled? }
36
37
  end
37
38
 
38
39
  def test_select_list_getAllContents
39
- assert_raises(UnknownObjectException) { $ff.select_list(:xpath, "//select[@name='NoName']").getAllContents }
40
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getAllContents }
40
41
  assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
41
- $ff.select_list(:xpath, "//select[@name='sel1']").getAllContents)
42
+ browser.select_list(:xpath, "//select[@name='sel1']").getAllContents)
42
43
  end
43
44
 
44
45
  def test_select_list_getSelectedItems
45
- assert_raises(UnknownObjectException) { $ff.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
46
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
46
47
  assert_equal( ["Option 3" ] ,
47
- $ff.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
48
+ browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
48
49
  assert_equal( ["Option 3" , "Option 6" ] ,
49
- $ff.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
50
+ browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
50
51
  end
51
52
 
53
+ tag_method :test_clearSelection, :fails_on_ie
52
54
  def test_clearSelection
53
- assert_raises(UnknownObjectException) { $ff.select_list(:xpath, "//select[@name='NoName']").clearSelection }
54
- $ff.select_list(:xpath, "//select[@name='sel1']").clearSelection
55
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").clearSelection }
56
+ browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
55
57
 
56
58
  # the box sel1 has no ability to have a de-selected item
57
59
  # By default Option 1 will be selected
58
- assert_equal( ["Option 1" ] , $ff.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
60
+ assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
59
61
 
60
- $ff.select_list(:xpath, "//select[@name='sel2']").clearSelection
61
- assert_equal( [ ] , $ff.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
62
+ browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
63
+ assert_equal( [ ] , browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
62
64
  end
63
65
 
64
66
  def test_select_list_select
65
- assert_raises(UnknownObjectException) { $ff.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
66
- assert_raises(NoValueFoundException) { $ff.select_list(:xpath, "//select[@name='sel1']").select("missing item") }
67
- assert_raises(NoValueFoundException) { $ff.select_list(:xpath, "//select[@name='sel1']").select(/missing/) }
67
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
68
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select("missing item") }
69
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select(/missing/) }
68
70
 
69
71
  # the select method keeps any currently selected items - use the clear selectcion method first
70
- $ff.select_list(:xpath, "//select[@name='sel1']").clearSelection
71
- $ff.select_list(:xpath, "//select[@name='sel1']").select("Option 1")
72
- assert_equal( ["Option 1" ] , $ff.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
72
+ browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
73
+ browser.select_list(:xpath, "//select[@name='sel1']").select("Option 1")
74
+ assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
73
75
 
74
- $ff.select_list(:xpath, "//select[@name='sel1']").clearSelection
75
- $ff.select_list(:xpath, "//select[@name='sel1']").select(/2/)
76
- assert_equal( ["Option 2" ] , $ff.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
76
+ browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
77
+ browser.select_list(:xpath, "//select[@name='sel1']").select(/2/)
78
+ assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
77
79
 
78
- $ff.select_list(:xpath, "//select[@name='sel2']").clearSelection
79
- $ff.select_list(:xpath, "//select[@name='sel2']").select( /2/ )
80
- $ff.select_list(:xpath, "//select[@name='sel2']").select( /4/ )
80
+ browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
81
+ browser.select_list(:xpath, "//select[@name='sel2']").select( /2/ )
82
+ browser.select_list(:xpath, "//select[@name='sel2']").select( /4/ )
81
83
  assert_equal( ["Option 2" , "Option 4" ] ,
82
- $ff.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
84
+ browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
83
85
 
84
86
  # these are to test the onchange event
85
87
  # the event shouldnt get fired, as this is the selected item
86
- $ff.select_list(:xpath, "//select[@name='sel3']").select( /3/ )
87
- assert_false($ff.text.include?("Pass") )
88
+ browser.select_list(:xpath, "//select[@name='sel3']").select( /3/ )
89
+ assert_false(browser.text.include?("Pass") )
88
90
  end
89
91
 
90
92
  def test_select_list_select2
91
93
  # the event should get fired
92
- $ff.select_list(:xpath, "//select[@name='sel3']").select( /2/ )
93
- assert($ff.text.include?("PASS") )
94
+ browser.select_list(:xpath, "//select[@name='sel3']").select( /2/ )
95
+ assert(browser.text.include?("PASS") )
94
96
  end
95
97
 
96
98
  def test_select_list_select_using_value
97
- assert_raises(UnknownObjectException) { $ff.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
98
- assert_raises(NoValueFoundException) { $ff.select_list(:xpath, "//select[@name='sel1']").select_value("missing item") }
99
- assert_raises(NoValueFoundException) { $ff.select_list(:xpath, "//select[@name='sel1']").select_value(/missing/) }
99
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']").getSelectedItems }
100
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select_value("missing item") }
101
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']").select_value(/missing/) }
100
102
 
101
103
  # the select method keeps any currently selected items - use the clear selectcion method first
102
- $ff.select_list(:xpath, "//select[@name='sel1']").clearSelection
103
- $ff.select_list(:xpath, "//select[@name='sel1']").select_value("o1")
104
- assert_equal( ["Option 1" ] , $ff.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
104
+ browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
105
+ browser.select_list(:xpath, "//select[@name='sel1']").select_value("o1")
106
+ assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
105
107
 
106
- $ff.select_list(:xpath, "//select[@name='sel1']").clearSelection
107
- $ff.select_list(:xpath, "//select[@name='sel1']").select_value(/2/)
108
- assert_equal( ["Option 2" ] , $ff.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
108
+ browser.select_list(:xpath, "//select[@name='sel1']").clearSelection
109
+ browser.select_list(:xpath, "//select[@name='sel1']").select_value(/2/)
110
+ assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']").getSelectedItems)
109
111
 
110
- $ff.select_list(:xpath, "//select[@name='sel2']").clearSelection
111
- $ff.select_list(:xpath, "//select[@name='sel2']").select( /2/ )
112
- $ff.select_list(:xpath, "//select[@name='sel2']").select( /4/ )
113
- assert_equal( ["Option 2" , "Option 4" ] , $ff.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
112
+ browser.select_list(:xpath, "//select[@name='sel2']").clearSelection
113
+ browser.select_list(:xpath, "//select[@name='sel2']").select( /2/ )
114
+ browser.select_list(:xpath, "//select[@name='sel2']").select( /4/ )
115
+ assert_equal( ["Option 2" , "Option 4" ] , browser.select_list(:xpath, "//select[@name='sel2']").getSelectedItems)
114
116
 
115
117
  # these are to test the onchange event
116
118
  # the event shouldnt get fired, as this is the selected item
117
- $ff.select_list(:xpath, "//select[@name='sel3']").select_value( /3/ )
118
- assert_false($ff.text.include?("Pass") )
119
+ browser.select_list(:xpath, "//select[@name='sel3']").select_value( /3/ )
120
+ assert_false(browser.text.include?("Pass") )
119
121
  end
120
122
 
121
123
  def test_select_list_select_using_value2
122
124
  # the event should get fired
123
- $ff.select_list(:xpath, "//select[@name='sel3']").select_value( /2/ )
124
- assert($ff.text.include?("PASS") )
125
+ browser.select_list(:xpath, "//select[@name='sel3']").select_value( /2/ )
126
+ assert(browser.text.include?("PASS") )
125
127
  end
126
128
 
127
129
  end