firewatir 1.2.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
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,49 +1,49 @@
1
1
  # feature tests for Frames
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_Frames < Test::Unit::TestCase
8
- include FireWatir
8
+
9
9
 
10
10
  def setup
11
- $ff.goto($htmlRoot + "frame_buttons.html")
11
+ goto_page("frame_buttons.html")
12
12
  end
13
13
 
14
14
  def test_frame_no_what
15
- assert_raises(UnknownFrameException) { $ff.frame("missingFrame").button(:id, "b2").enabled? }
16
- assert_raises(UnknownObjectException) { $ff.frame("buttonFrame2").button(:id, "b2").enabled? }
17
- assert($ff.frame("buttonFrame").button(:id, "b2").enabled?)
18
- assert(!$ff.frame("buttonFrame").button(:caption, "Disabled Button").enabled?)
15
+ assert_raises(UnknownFrameException) { browser.frame("missingFrame").button(:id, "b2").enabled? }
16
+ assert_raises(UnknownObjectException) { browser.frame("buttonFrame2").button(:id, "b2").enabled? }
17
+ assert(browser.frame("buttonFrame").button(:id, "b2").enabled?)
18
+ assert_false(browser.frame("buttonFrame").button(:caption, "Disabled Button").enabled?)
19
19
  end
20
20
 
21
21
  def test_frame_using_name
22
- assert_raises(UnknownFrameException) { $ff.frame(:name , "missingFrame").button(:id, "b2").enabled? }
23
- assert_raises(UnknownObjectException) { $ff.frame(:name, "buttonFrame2").button(:id, "b2").enabled? }
24
- assert($ff.frame(:name, "buttonFrame").button(:id, "b2").enabled?)
25
- assert(!$ff.frame(:name , "buttonFrame").button(:caption, "Disabled Button").enabled?)
22
+ assert_raises(UnknownFrameException) { browser.frame(:name , "missingFrame").button(:id, "b2").enabled? }
23
+ assert_raises(UnknownObjectException) { browser.frame(:name, "buttonFrame2").button(:id, "b2").enabled? }
24
+ assert(browser.frame(:name, "buttonFrame").button(:id, "b2").enabled?)
25
+ assert_false(browser.frame(:name , "buttonFrame").button(:caption, "Disabled Button").enabled?)
26
26
  end
27
27
 
28
28
  def test_frame_using_name_and_regexp
29
- assert_raises(UnknownFrameException) { $ff.frame(:name , /missingFrame/).button(:id, "b2").enabled? }
30
- assert($ff.frame(:name, /button/).button(:id, "b2").enabled?)
29
+ assert_raises(UnknownFrameException) { browser.frame(:name , /missingFrame/).button(:id, "b2").enabled? }
30
+ assert(browser.frame(:name, /button/).button(:id, "b2").enabled?)
31
31
  end
32
32
 
33
33
  def test_frame_using_index
34
- assert_raises(UnknownFrameException) { $ff.frame(:index, 8).button(:id, "b2").enabled? }
35
- assert_raises(UnknownObjectException) { $ff.frame(:index, 2).button(:id, "b2").enabled? }
36
- assert($ff.frame(:index, 1 ).button(:id, "b2").enabled?)
37
- assert(!$ff.frame(:index, 1).button(:caption, "Disabled Button").enabled?)
34
+ assert_raises(UnknownFrameException) { browser.frame(:index, 8).button(:id, "b2").enabled? }
35
+ assert_raises(UnknownObjectException) { browser.frame(:index, 2).button(:id, "b2").enabled? }
36
+ assert(browser.frame(:index, 1 ).button(:id, "b2").enabled?)
37
+ assert_false(browser.frame(:index, 1).button(:caption, "Disabled Button").enabled?)
38
38
  end
39
39
 
40
40
  # def test_frame_with_invalid_attribute
41
- # assert_raises(ArgumentError) { $ff.frame(:blah, 'no_such_thing').button(:id, "b2").enabled? }
41
+ # assert_raises(ArgumentError) { browser.frame(:blah, 'no_such_thing').button(:id, "b2").enabled? }
42
42
  # end
43
43
 
44
44
  def test_preset_frame
45
45
  # with ruby's instance_eval, we are able to use the same frame for several actions
46
- results = $ff.frame("buttonFrame").instance_eval do [
46
+ results = browser.frame("buttonFrame").instance_eval do [
47
47
  button(:id, "b2").enabled?,
48
48
  button(:caption, "Disabled Button").enabled?
49
49
  ]
@@ -54,54 +54,54 @@ class TC_Frames < Test::Unit::TestCase
54
54
  end
55
55
 
56
56
  class TC_Frames2 < Test::Unit::TestCase
57
- include FireWatir
57
+
58
58
 
59
59
  def setup
60
- $ff.goto($htmlRoot + "frame_multi.html")
60
+ goto_page("frame_multi.html")
61
61
  end
62
62
 
63
63
  def test_frame_with_no_name
64
- assert_raises(UnknownFrameException) { $ff.frame(:name , "missingFrame").button(:id, "b2").enabled? }
64
+ assert_raises(UnknownFrameException) { browser.frame(:name , "missingFrame").button(:id, "b2").enabled? }
65
65
  end
66
66
 
67
67
  def test_frame_by_id
68
- assert_raises(UnknownFrameException) { $ff.frame(:id , "missingFrame").button(:id, "b2").enabled? }
69
- assert($ff.frame(:id, 'first_frame').button(:id, "b2").enabled?)
70
- assert(/.*Test page for buttons.*/ =~ $ff.frame(:id, 'first_frame').html)
68
+ assert_raises(UnknownFrameException) { browser.frame(:id , "missingFrame").button(:id, "b2").enabled? }
69
+ assert(browser.frame(:id, 'first_frame').button(:id, "b2").enabled?)
70
+ assert(/.*Test page for buttons.*/ =~ browser.frame(:id, 'first_frame').html)
71
71
  end
72
72
  end
73
73
 
74
74
  class TC_NestedFrames < Test::Unit::TestCase
75
- include FireWatir
75
+
76
76
 
77
77
  def setup
78
- $ff.goto($htmlRoot + "nestedFrames.html")
78
+ goto_page("nestedFrames.html")
79
79
  end
80
80
 
81
81
  def test_frame
82
- assert_raises(UnknownFrameException) { $ff.frame("missingFrame").button(:id, "b2").enabled? }
83
- assert_raises(UnknownFrameException) { $ff.frame("nestedFrame").frame("subFrame").button(:id, "b2").enabled? }
84
- assert($ff.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").enabled?)
85
- $ff.frame("nestedFrame").frame("senderFrame").text_field(:index, "1").set("Hello")
86
- $ff.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").click
87
- assert($ff.frame("nestedFrame").frame("receiverFrame").text_field(:name, "receiverText").verify_contains("Hello"))
82
+ assert_raises(UnknownFrameException) { browser.frame("missingFrame").button(:id, "b2").enabled? }
83
+ assert_raises(UnknownFrameException) { browser.frame("nestedFrame").frame("subFrame").button(:id, "b2").enabled? }
84
+ assert(browser.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").enabled?)
85
+ browser.frame("nestedFrame").frame("senderFrame").text_field(:index, "1").set("Hello")
86
+ browser.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").click
87
+ assert(browser.frame("nestedFrame").frame("receiverFrame").text_field(:name, "receiverText").verify_contains("Hello"))
88
88
  end
89
89
 
90
90
  end
91
91
 
92
92
  class TC_IFrames < Test::Unit::TestCase
93
- include FireWatir
93
+
94
94
 
95
95
  def setup
96
- $ff.goto($htmlRoot + "iframeTest.html")
96
+ goto_page("iframeTest.html")
97
97
  end
98
98
 
99
99
  def test_Iframe
100
- f = $ff.frame("senderFrame")
100
+ f = browser.frame("senderFrame")
101
101
  f.text_field(:name, "textToSend").set("Hello World")
102
- $ff.frame("senderFrame").text_field(:name , "textToSend").set( "Hello World")
103
- $ff.frame("senderFrame").button(:index, 1).click
104
- assert( $ff.frame("receiverFrame").text_field(:name , "receiverText").verify_contains("Hello World") )
102
+ browser.frame("senderFrame").text_field(:name , "textToSend").set( "Hello World")
103
+ browser.frame("senderFrame").button(:index, 1).click
104
+ assert( browser.frame("receiverFrame").text_field(:name , "receiverText").verify_contains("Hello World") )
105
105
  end
106
106
 
107
107
  end
@@ -109,11 +109,12 @@ end
109
109
  require 'unittests/iostring'
110
110
  class TC_show_frames < Test::Unit::TestCase
111
111
  include MockStdoutTestCase
112
+ tags :fails_on_ie
112
113
 
113
114
  def capture_and_compare(page, expected)
114
- $ff.goto($htmlRoot + page)
115
+ goto_page(page)
115
116
  $stdout = @mockout
116
- $ff.showFrames
117
+ browser.showFrames
117
118
  assert_equal(expected, @mockout)
118
119
  end
119
120
 
@@ -1,73 +1,73 @@
1
1
  # feature tests for Input Hidden elements
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_Hidden_Fields < Test::Unit::TestCase
8
8
  def setup
9
- $ff.goto($htmlRoot + "forms3.html")
9
+ goto_page("forms3.html")
10
10
  end
11
11
 
12
12
  def test_hidden
13
13
 
14
14
  # test using index
15
- assert( $ff.hidden(:index,1).exists? )
16
- assert( $ff.hidden(:index,2).exists? )
17
- assert_false( $ff.hidden(:index,3).exists? )
15
+ assert( browser.hidden(:index,1).exists? )
16
+ assert( browser.hidden(:index,2).exists? )
17
+ assert_false( browser.hidden(:index,3).exists? )
18
18
 
19
- $ff.hidden(:index,1).value = 44
20
- $ff.hidden(:index,2).value = 55
19
+ browser.hidden(:index,1).value = 44
20
+ browser.hidden(:index,2).value = 55
21
21
 
22
- $ff.button(:value , "Show Hidden").click
22
+ browser.button(:value , "Show Hidden").click
23
23
 
24
- assert_equal("44" , $ff.text_field(:name , "vis1").value )
25
- assert_equal("55" , $ff.text_field(:name , "vis2").value )
24
+ assert_equal("44" , browser.text_field(:name , "vis1").value )
25
+ assert_equal("55" , browser.text_field(:name , "vis2").value )
26
26
 
27
27
  # test using name and ID
28
- assert( $ff.hidden(:name ,"hid1").exists? )
29
- assert( $ff.hidden(:id,"hidden_1").exists? )
30
- assert_false( $ff.hidden(:name,"hidden_44").exists? )
31
- assert_false( $ff.hidden(:id,"hidden_55").exists? )
28
+ assert( browser.hidden(:name ,"hid1").exists? )
29
+ assert( browser.hidden(:id,"hidden_1").exists? )
30
+ assert_false( browser.hidden(:name,"hidden_44").exists? )
31
+ assert_false( browser.hidden(:id,"hidden_55").exists? )
32
32
 
33
- $ff.hidden(:name ,"hid1").value = 444
34
- $ff.hidden(:id,"hidden_1").value = 555
33
+ browser.hidden(:name ,"hid1").value = 444
34
+ browser.hidden(:id,"hidden_1").value = 555
35
35
 
36
- $ff.button(:value , "Show Hidden").click
36
+ browser.button(:value , "Show Hidden").click
37
37
 
38
- assert_equal("444" , $ff.text_field(:name , "vis1").value )
39
- assert_equal("555" , $ff.text_field(:name ,"vis2").value )
38
+ assert_equal("444" , browser.text_field(:name , "vis1").value )
39
+ assert_equal("555" , browser.text_field(:name ,"vis2").value )
40
40
 
41
41
  # test the over-ridden append method
42
- $ff.hidden(:name ,"hid1").append("a")
43
- $ff.button(:value , "Show Hidden").click
44
- assert_equal("444a" , $ff.text_field(:name , "vis1").value )
45
- assert_equal("555" , $ff.text_field(:name ,"vis2").value )
42
+ browser.hidden(:name ,"hid1").append("a")
43
+ browser.button(:value , "Show Hidden").click
44
+ assert_equal("444a" , browser.text_field(:name , "vis1").value )
45
+ assert_equal("555" , browser.text_field(:name ,"vis2").value )
46
46
 
47
47
  # test the over-ridden clear method
48
- $ff.hidden(:name ,"hid1").clear
49
- $ff.button(:value , "Show Hidden").click
50
- assert_equal("" , $ff.text_field(:name , "vis1").value )
51
- assert_equal("555" , $ff.text_field(:name ,"vis2").value )
48
+ browser.hidden(:name ,"hid1").clear
49
+ browser.button(:value , "Show Hidden").click
50
+ assert_equal("" , browser.text_field(:name , "vis1").value )
51
+ assert_equal("555" , browser.text_field(:name ,"vis2").value )
52
52
 
53
53
  # test using a form
54
- assert( $ff.form(:name , "has_a_hidden").hidden(:name ,"hid1").exists? )
55
- assert( $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_1").exists? )
56
- assert_false( $ff.form(:name , "has_a_hidden").hidden(:name,"hidden_44").exists? )
57
- assert_false( $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_55").exists? )
54
+ assert( browser.form(:name , "has_a_hidden").hidden(:name ,"hid1").exists? )
55
+ assert( browser.form(:name , "has_a_hidden").hidden(:id,"hidden_1").exists? )
56
+ assert_false( browser.form(:name , "has_a_hidden").hidden(:name,"hidden_44").exists? )
57
+ assert_false( browser.form(:name , "has_a_hidden").hidden(:id,"hidden_55").exists? )
58
58
 
59
- $ff.form(:name , "has_a_hidden").hidden(:name ,"hid1").value = 222
60
- $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_1").value = 333
59
+ browser.form(:name , "has_a_hidden").hidden(:name ,"hid1").value = 222
60
+ browser.form(:name , "has_a_hidden").hidden(:id,"hidden_1").value = 333
61
61
 
62
- $ff.button(:value , "Show Hidden").click
62
+ browser.button(:value , "Show Hidden").click
63
63
 
64
- assert_equal("222" , $ff.text_field(:name , "vis1").value )
65
- assert_equal("333" , $ff.text_field(:name ,"vis2").value )
64
+ assert_equal("222" , browser.text_field(:name , "vis1").value )
65
+ assert_equal("333" , browser.text_field(:name ,"vis2").value )
66
66
 
67
67
  # iterators
68
- assert_equal(2, $ff.hiddens.length)
68
+ assert_equal(2, browser.hiddens.length)
69
69
  count =1
70
- $ff.hiddens.each do |h|
70
+ browser.hiddens.each do |h|
71
71
  case count
72
72
  when 1
73
73
  assert_equal( "", h.id)
@@ -79,7 +79,7 @@ class TC_Hidden_Fields < Test::Unit::TestCase
79
79
  count+=1
80
80
  end
81
81
 
82
- assert_equal("hid1" , $ff.hiddens[1].name )
83
- assert_equal("hidden_1" , $ff.hiddens[2].id )
82
+ assert_equal("hid1" , browser.hiddens[1].name )
83
+ assert_equal("hidden_1" , browser.hiddens[2].id )
84
84
  end
85
85
  end
@@ -1,60 +1,60 @@
1
1
  # feature tests for Input Hidden elements
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_Hidden_Fields_XPath < Test::Unit::TestCase
8
8
  def setup
9
- $ff.goto($htmlRoot + "forms3.html")
9
+ goto_page("forms3.html")
10
10
  end
11
11
 
12
12
  def test_hidden
13
13
 
14
14
  # test using name and ID
15
- assert( $ff.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").exists? )
16
- assert( $ff.hidden(:xpath,"//input[@type='hidden' and @id='hidden_1']").exists? )
17
- assert_false( $ff.hidden(:xpath,"//input[@type='hidden' and @name='hidden_44']").exists? )
18
- assert_false( $ff.hidden(:xpath,"//input[@type='hidden' and @id='hidden_55']").exists? )
15
+ assert( browser.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").exists? )
16
+ assert( browser.hidden(:xpath,"//input[@type='hidden' and @id='hidden_1']").exists? )
17
+ assert_false( browser.hidden(:xpath,"//input[@type='hidden' and @name='hidden_44']").exists? )
18
+ assert_false( browser.hidden(:xpath,"//input[@type='hidden' and @id='hidden_55']").exists? )
19
19
 
20
- $ff.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").value = 444
21
- $ff.hidden(:xpath,"//input[@type='hidden' and @id='hidden_1']").value = 555
20
+ browser.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").value = 444
21
+ browser.hidden(:xpath,"//input[@type='hidden' and @id='hidden_1']").value = 555
22
22
 
23
- $ff.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
23
+ browser.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
24
24
 
25
- assert_equal("444" , $ff.text_field(:xpath , "//input[@name='vis1']").value )
26
- assert_equal("555" , $ff.text_field(:xpath ,"//input[@name='vis2']").value )
25
+ assert_equal("444" , browser.text_field(:xpath , "//input[@name='vis1']").value )
26
+ assert_equal("555" , browser.text_field(:xpath ,"//input[@name='vis2']").value )
27
27
 
28
28
  # test the over-ridden append method
29
- $ff.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").append("a")
30
- $ff.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
31
- assert_equal("444a" , $ff.text_field(:xpath , "//input[@name='vis1']").value )
32
- assert_equal("555" , $ff.text_field(:xpath ,"//input[@name='vis2']").value )
29
+ browser.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").append("a")
30
+ browser.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
31
+ assert_equal("444a" , browser.text_field(:xpath , "//input[@name='vis1']").value )
32
+ assert_equal("555" , browser.text_field(:xpath ,"//input[@name='vis2']").value )
33
33
 
34
34
  # test the over-ridden clear method
35
- $ff.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").clear
36
- $ff.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
37
- assert_equal("" , $ff.text_field(:xpath , "//input[@name='vis1']").value )
38
- assert_equal("555" , $ff.text_field(:xpath ,"//input[@name='vis2']").value )
35
+ browser.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").clear
36
+ browser.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
37
+ assert_equal("" , browser.text_field(:xpath , "//input[@name='vis1']").value )
38
+ assert_equal("555" , browser.text_field(:xpath ,"//input[@name='vis2']").value )
39
39
 
40
40
  # test using a form
41
- #assert( $ff.form(:name , "has_a_hidden").hidden(:name ,"hid1").exists? )
42
- #assert( $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_1").exists? )
43
- #assert_false( $ff.form(:name , "has_a_hidden").hidden(:name,"hidden_44").exists? )
44
- #assert_false( $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_55").exists? )
41
+ #assert( browser.form(:name , "has_a_hidden").hidden(:name ,"hid1").exists? )
42
+ #assert( browser.form(:name , "has_a_hidden").hidden(:id,"hidden_1").exists? )
43
+ #assert_false( browser.form(:name , "has_a_hidden").hidden(:name,"hidden_44").exists? )
44
+ #assert_false( browser.form(:name , "has_a_hidden").hidden(:id,"hidden_55").exists? )
45
45
 
46
- #$ff.form(:name , "has_a_hidden").hidden(:name ,"hid1").value = 222
47
- #$ff.form(:name , "has_a_hidden").hidden(:id,"hidden_1").value = 333
46
+ #browser.form(:name , "has_a_hidden").hidden(:name ,"hid1").value = 222
47
+ #browser.form(:name , "has_a_hidden").hidden(:id,"hidden_1").value = 333
48
48
 
49
- #$ff.button(:value , "Show Hidden").click
49
+ #browser.button(:value , "Show Hidden").click
50
50
 
51
- #assert_equal("222" , $ff.text_field(:name , "vis1").value )
52
- #assert_equal("333" , $ff.text_field(:name ,"vis2").value )
51
+ #assert_equal("222" , browser.text_field(:name , "vis1").value )
52
+ #assert_equal("333" , browser.text_field(:name ,"vis2").value )
53
53
 
54
54
  # iterators
55
- #assert_equal(2, $ff.hiddens.length)
55
+ #assert_equal(2, browser.hiddens.length)
56
56
  #count =1
57
- #$ff.hiddens.each do |h|
57
+ #browser.hiddens.each do |h|
58
58
  # case count
59
59
  # when 1
60
60
  # assert_equal( "", h.id)
@@ -66,7 +66,7 @@ class TC_Hidden_Fields_XPath < Test::Unit::TestCase
66
66
  # count+=1
67
67
  #end
68
68
 
69
- #assert_equal("hid1" , $ff.hiddens[1].name )
70
- #assert_equal("hidden_1" , $ff.hiddens[2].id )
69
+ #assert_equal("hid1" , browser.hiddens[1].name )
70
+ #assert_equal("hidden_1" , browser.hiddens[2].id )
71
71
  end
72
72
  end
@@ -1,16 +1,16 @@
1
1
  # feature tests for Images
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
  require 'ftools'
7
7
  require 'webrick'
8
8
 
9
9
  class TC_Images < Test::Unit::TestCase
10
- include FireWatir
10
+
11
11
 
12
12
  def setup
13
- $ff.goto($htmlRoot + "images1.html")
13
+ goto_page("images1.html")
14
14
  @saved_img_path = build_path("sample.img.dat");
15
15
  clean_saved_image
16
16
  end
@@ -19,136 +19,136 @@ class TC_Images < Test::Unit::TestCase
19
19
  clean_saved_image
20
20
  end
21
21
  # def test_show_all_objects
22
- # $ff.show_all_objects
22
+ # browser.show_all_objects
23
23
  # end
24
24
 
25
25
  def test_imageExists
26
- assert( ! $ff.image(:name , "missing_name").exists? )
27
- assert( $ff.image(:name , "circle").exists? )
28
- assert( $ff.image(:name , /circ/ ).exists? )
26
+ assert( ! browser.image(:name , "missing_name").exists? )
27
+ assert( browser.image(:name , "circle").exists? )
28
+ assert( browser.image(:name , /circ/ ).exists? )
29
29
 
30
- assert( ! $ff.image(:id , "missing_id").exists? )
31
- assert( $ff.image(:id , "square").exists? )
32
- assert( $ff.image(:id , /squ/ ).exists? )
30
+ assert( ! browser.image(:id , "missing_id").exists? )
31
+ assert( browser.image(:id , "square").exists? )
32
+ assert( browser.image(:id , /squ/ ).exists? )
33
33
 
34
- assert( ! $ff.image(:src, "missingsrc.gif").exists? )
34
+ assert( ! browser.image(:src, "missingsrc.gif").exists? )
35
35
 
36
- assert( $ff.image(:src, /images\/triangle.jpg/).exists? )
37
- assert( $ff.image(:src , /triangle/ ).exists? )
36
+ assert( browser.image(:src, /images\/triangle.jpg/).exists? )
37
+ assert( browser.image(:src , /triangle/ ).exists? )
38
38
 
39
- assert( $ff.image(:alt , "circle" ).exists? )
40
- assert( $ff.image(:alt , /cir/ ).exists? )
39
+ assert( browser.image(:alt , "circle" ).exists? )
40
+ assert( browser.image(:alt , /cir/ ).exists? )
41
41
 
42
- assert( ! $ff.image(:alt , "triangle" ).exists? )
43
- assert( ! $ff.image(:alt , /tri/ ).exists? )
42
+ assert( ! browser.image(:alt , "triangle" ).exists? )
43
+ assert( ! browser.image(:alt , /tri/ ).exists? )
44
44
 
45
- assert( $ff.image(:title, 'square_image').exists? )
46
- assert( ! $ff.image(:title, 'pentagram').exists? )
45
+ assert( browser.image(:title, 'square_image').exists? )
46
+ assert( ! browser.image(:title, 'pentagram').exists? )
47
47
  end
48
48
 
49
49
  def test_image_click
50
- assert_raises(UnknownObjectException ) { $ff.image(:name, "no_image_with_this").click }
51
- assert_raises(UnknownObjectException ) { $ff.image(:id, "no_image_with_this").click }
52
- assert_raises(UnknownObjectException ) { $ff.image(:src, "no_image_with_this").click}
53
- assert_raises(UnknownObjectException ) { $ff.image(:alt, "no_image_with_this").click}
50
+ assert_raises(UnknownObjectException ) { browser.image(:name, "no_image_with_this").click }
51
+ assert_raises(UnknownObjectException ) { browser.image(:id, "no_image_with_this").click }
52
+ assert_raises(UnknownObjectException ) { browser.image(:src, "no_image_with_this").click}
53
+ assert_raises(UnknownObjectException ) { browser.image(:alt, "no_image_with_this").click}
54
54
 
55
55
  # test for bug 1882
56
- $ff.text_field(:name , "text1").clear
57
- $ff.button(:value , /Pos/ ).click
58
- assert_equal('clicked' , $ff.text_field(:name , "text1" ).value )
56
+ browser.text_field(:name , "text1").clear
57
+ browser.button(:value , /Pos/ ).click
58
+ assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
59
59
 
60
60
  # test for disabled button. Click the button to make it disabled
61
- $ff.button(:name , 'disable_img').click
62
- assert( $ff.image(:name , 'disabler_test').disabled )
61
+ browser.button(:name , 'disable_img').click
62
+ assert( browser.image(:name , 'disabler_test').disabled )
63
63
 
64
64
  # Click button again to make it enabled.
65
- $ff.button(:name , 'disable_img').click
66
- assert( ! $ff.image(:name , 'disabler_test').disabled )
65
+ browser.button(:name , 'disable_img').click
66
+ assert( ! browser.image(:name , 'disabler_test').disabled )
67
67
 
68
68
 
69
- $ff.image(:src, /button/).click
70
- #assert($ff.text.include?("PASS") )
71
- assert($ff.contains_text("PASS") )
69
+ browser.image(:src, /button/).click
70
+ #assert(browser.text.include?("PASS") )
71
+ assert(browser.contains_text("PASS") )
72
72
  end
73
73
 
74
74
  # TODO: Need to see alternative for this in Mozilla
75
75
  #def test_imageHasLoaded
76
- # assert_raises(UnknownObjectException ) { $ff.image(:name, "no_image_with_this").hasLoaded? }
77
- # assert_raises(UnknownObjectException ) { $ff.image(:id, "no_image_with_this").hasLoaded? }
78
- # assert_raises(UnknownObjectException ) { $ff.image(:src, "no_image_with_this").hasLoaded? }
79
- # assert_raises(UnknownObjectException ) { $ff.image(:alt, "no_image_with_this").hasLoaded? }
76
+ # assert_raises(UnknownObjectException ) { browser.image(:name, "no_image_with_this").hasLoaded? }
77
+ # assert_raises(UnknownObjectException ) { browser.image(:id, "no_image_with_this").hasLoaded? }
78
+ # assert_raises(UnknownObjectException ) { browser.image(:src, "no_image_with_this").hasLoaded? }
79
+ # assert_raises(UnknownObjectException ) { browser.image(:alt, "no_image_with_this").hasLoaded? }
80
80
  #
81
- # assert( ! $ff.image(:name, "themissingimage").hasLoaded? )
82
- # assert( $ff.image(:name, "circle").hasLoaded? )
81
+ # assert( ! browser.image(:name, "themissingimage").hasLoaded? )
82
+ # assert( browser.image(:name, "circle").hasLoaded? )
83
83
  #
84
- # assert( $ff.image(:alt, "circle").hasLoaded? )
85
- # assert( $ff.image(:alt, /cir/ ).hasLoaded? )
84
+ # assert( browser.image(:alt, "circle").hasLoaded? )
85
+ # assert( browser.image(:alt, /cir/ ).hasLoaded? )
86
86
  #end
87
87
 
88
88
  def test_image_properties
89
89
  # TODO: Need to see alternative for this in Mozilla
90
- #assert_raises(UnknownObjectException ) { $ff.image(:name, "no_image_with_this").hasLoaded? }
91
- #assert_raises(UnknownObjectException ) { $ff.image(:id, "no_image_with_this").hasLoaded? }
92
- #assert_raises(UnknownObjectException ) { $ff.image(:src, "no_image_with_this").hasLoaded? }
93
- #assert_raises(UnknownObjectException ) { $ff.image(:index, 82).hasLoaded? }
90
+ #assert_raises(UnknownObjectException ) { browser.image(:name, "no_image_with_this").hasLoaded? }
91
+ #assert_raises(UnknownObjectException ) { browser.image(:id, "no_image_with_this").hasLoaded? }
92
+ #assert_raises(UnknownObjectException ) { browser.image(:src, "no_image_with_this").hasLoaded? }
93
+ #assert_raises(UnknownObjectException ) { browser.image(:index, 82).hasLoaded? }
94
94
 
95
- assert_raises(UnknownObjectException ) { $ff.image(:index, 82).name }
96
- assert_raises(UnknownObjectException ) { $ff.image(:index, 82).id }
97
- assert_raises(UnknownObjectException ) { $ff.image(:index, 82).src }
98
- assert_raises(UnknownObjectException ) { $ff.image(:index, 82).value }
99
- assert_raises(UnknownObjectException ) { $ff.image(:index, 82).height }
100
- assert_raises(UnknownObjectException ) { $ff.image(:index, 82).width }
95
+ assert_raises(UnknownObjectException ) { browser.image(:index, 82).name }
96
+ assert_raises(UnknownObjectException ) { browser.image(:index, 82).id }
97
+ assert_raises(UnknownObjectException ) { browser.image(:index, 82).src }
98
+ assert_raises(UnknownObjectException ) { browser.image(:index, 82).value }
99
+ assert_raises(UnknownObjectException ) { browser.image(:index, 82).height }
100
+ assert_raises(UnknownObjectException ) { browser.image(:index, 82).width }
101
101
 
102
102
  # TODO: Need to see alternative for this in Mozilla
103
- #assert_raises(UnknownObjectException ) { $ff.image(:index, 82).fileCreatedDate }
104
- #assert_raises(UnknownObjectException ) { $ff.image(:index, 82).fileSize }
103
+ #assert_raises(UnknownObjectException ) { browser.image(:index, 82).fileCreatedDate }
104
+ #assert_raises(UnknownObjectException ) { browser.image(:index, 82).fileSize }
105
105
 
106
- assert_raises(UnknownObjectException ) { $ff.image(:index, 82).alt}
107
- assert_raises(UnknownObjectException ) { $ff.image(:index, 82).title}
106
+ assert_raises(UnknownObjectException ) { browser.image(:index, 82).alt}
107
+ assert_raises(UnknownObjectException ) { browser.image(:index, 82).title}
108
108
 
109
- assert_equal( "" , $ff.image(:index, 2).name )
110
- assert_equal( "square" , $ff.image(:index, 2).id )
111
- assert_match( /square\.jpg/i ,$ff.image(:index, 2).src )
112
- assert_equal( "" , $ff.image(:index, 2).value )
113
- assert_equal( "88" , $ff.image(:index, 2).height )
114
- assert_equal( "88" , $ff.image(:index, 2).width )
109
+ assert_equal( "" , browser.image(:index, 2).name )
110
+ assert_equal( "square" , browser.image(:index, 2).id )
111
+ assert_match( /square\.jpg/i ,browser.image(:index, 2).src )
112
+ assert_equal( "" , browser.image(:index, 2).value )
113
+ assert_equal( "88" , browser.image(:index, 2).height )
114
+ assert_equal( "88" , browser.image(:index, 2).width )
115
115
 
116
116
  # this line fails, as the date is when it is installed on the local oc, not the date the file was really created
117
- #assert_equal( "03/10/2005" , $ff.image(:index, 2).fileCreatedDate )
118
- #assert_equal( "788", $ff.image(:index, 2).fileSize )
117
+ #assert_equal( "03/10/2005" , browser.image(:index, 2).fileCreatedDate )
118
+ #assert_equal( "788", browser.image(:index, 2).fileSize )
119
119
 
120
120
  # tool tips: alt text + title
121
- assert_equal('circle' , $ff.image(:index, 6).alt)
122
- assert_equal( "" , $ff.image(:index, 2).alt)
123
- assert_equal('square_image', $ff.image(:id, 'square').title)
121
+ assert_equal('circle' , browser.image(:index, 6).alt)
122
+ assert_equal( "" , browser.image(:index, 2).alt)
123
+ assert_equal('square_image', browser.image(:id, 'square').title)
124
124
 
125
125
  # to string tests -- output should be verified!
126
- puts $ff.image(:name , "circle").to_s
127
- puts $ff.image(:index , 2).to_s
126
+ puts browser.image(:name , "circle").to_s
127
+ puts browser.image(:index , 2).to_s
128
128
  end
129
129
 
130
130
  def test_image_iterator
131
- assert_equal(6 , $ff.images.length)
132
- assert_equal("" , $ff.images[2].name )
133
- assert_equal("square", $ff.images[2].id )
134
- assert_match(/square/, $ff.images[2].src )
131
+ assert_equal(6 , browser.images.length)
132
+ assert_equal("" , browser.images[2].name )
133
+ assert_equal("square", browser.images[2].id )
134
+ assert_match(/square/, browser.images[2].src )
135
135
 
136
136
  index = 1
137
- $ff.images.each do |i|
138
- assert_equal( $ff.image(:index, index).id , i.id )
139
- assert_equal( $ff.image(:index, index).name , i.name )
140
- assert_equal( $ff.image(:index, index).src , i.src )
141
- assert_equal( $ff.image(:index, index).height , i.height.to_s )
142
- assert_equal( $ff.image(:index, index).width , i.width.to_s )
137
+ browser.images.each do |i|
138
+ assert_equal( browser.image(:index, index).id , i.id )
139
+ assert_equal( browser.image(:index, index).name , i.name )
140
+ assert_equal( browser.image(:index, index).src , i.src )
141
+ assert_equal( browser.image(:index, index).height , i.height.to_s )
142
+ assert_equal( browser.image(:index, index).width , i.width.to_s )
143
143
 
144
144
  index+=1
145
145
  end
146
- assert_equal( index-1 , $ff.images.length )
146
+ assert_equal( index-1 , browser.images.length )
147
147
  end
148
148
 
149
149
  #def test_save_local_image
150
- # $ff.images[1].save(build_windows_path("sample.img.dat"))
151
- # assert(File.compare(@saved_img_path, $ff.images[1].src.gsub(/^file:\/\/\//, '')))
150
+ # browser.images[1].save(build_windows_path("sample.img.dat"))
151
+ # assert(File.compare(@saved_img_path, browser.images[1].src.gsub(/^file:\/\/\//, '')))
152
152
  #end
153
153
 
154
154
  def clean_saved_image
@@ -165,13 +165,14 @@ class TC_Images < Test::Unit::TestCase
165
165
  end
166
166
 
167
167
  class TC_Images_Display < Test::Unit::TestCase
168
- include FireWatir
168
+
169
169
  include MockStdoutTestCase
170
170
 
171
+ tag_method :test_showImages, :fails_on_ie
171
172
  def test_showImages
172
- $ff.goto($htmlRoot + "images1.html")
173
+ goto_page("images1.html")
173
174
  $stdout = @mockout
174
- $ff.showImages
175
+ browser.showImages
175
176
  assert_equal(<<END_OF_MESSAGE, @mockout)
176
177
  There are 6 images
177
178
  image: name: