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,117 +1,118 @@
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_XPath < Test::Unit::TestCase
10
- include FireWatir
10
+
11
11
 
12
12
  def setup
13
13
  gotoImagePage
14
14
  end
15
15
 
16
16
  def gotoImagePage()
17
- $ff.goto($htmlRoot + "images1.html")
17
+ goto_page("images1.html")
18
18
  end
19
19
 
20
20
  def test_imageExists
21
- assert_false( $ff.image(:xpath , "//img[@name='missing_name']").exists? )
22
- assert( $ff.image(:xpath , "//img[@name='circle']").exists? )
23
- assert( $ff.image(:xpath , "//img[contains(@name , 'circ')]" ).exists? )
21
+ assert_false( browser.image(:xpath , "//img[@name='missing_name']").exists? )
22
+ assert( browser.image(:xpath , "//img[@name='circle']").exists? )
23
+ assert( browser.image(:xpath , "//img[contains(@name , 'circ')]" ).exists? )
24
24
 
25
- assert_false( $ff.image(:xpath , "//img[@id='missing_id']").exists? )
26
- assert( $ff.image(:xpath , "//img[@id='square']").exists? )
27
- assert( $ff.image(:xpath , "//img[contains(@id, 'squ')]" ).exists? )
25
+ assert_false( browser.image(:xpath , "//img[@id='missing_id']").exists? )
26
+ assert( browser.image(:xpath , "//img[@id='square']").exists? )
27
+ assert( browser.image(:xpath , "//img[contains(@id, 'squ')]" ).exists? )
28
28
 
29
- assert_false( $ff.image(:xpath , "//img[@src='missingsrc.gif']").exists? )
29
+ assert_false( browser.image(:xpath , "//img[@src='missingsrc.gif']").exists? )
30
30
 
31
31
  # BP -- This fails for me but not for Paul. It doesn't make sense to me that it should pass.
32
- # assert( $ff.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
33
- assert( $ff.image(:xpath , "//img[contains(@src , 'triangle')]" ).exists? )
32
+ # assert( browser.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
33
+ assert( browser.image(:xpath , "//img[contains(@src , 'triangle')]" ).exists? )
34
34
 
35
- assert( $ff.image(:alt , "circle" ).exists? )
36
- assert( $ff.image(:xpath , "//img[contains(@alt , 'cir')]" ).exists? )
35
+ assert( browser.image(:alt , "circle" ).exists? )
36
+ assert( browser.image(:xpath , "//img[contains(@alt , 'cir')]" ).exists? )
37
37
 
38
- assert_false( $ff.image(:alt , "triangle" ).exists? )
39
- assert_false( $ff.image(:xpath , "//img[contains(@alt , 'tri')]" ).exists? )
38
+ assert_false( browser.image(:alt , "triangle" ).exists? )
39
+ assert_false( browser.image(:xpath , "//img[contains(@alt , 'tri')]" ).exists? )
40
40
  end
41
41
 
42
+ tag_method :test_element_by_xpath_class, :fails_on_ie
42
43
  def test_element_by_xpath_class
43
44
  # FIXME getting HTMLAnchorElement instead of HTMLImageElement
44
45
  # TODO: This should return null if object is not there.
45
- #element = $ff.element_by_xpath("//img[@name='missing_name']")
46
+ #element = browser.element_by_xpath("//img[@name='missing_name']")
46
47
  #assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
47
- element = $ff.element_by_xpath("//img[@name='circle']")
48
- assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
49
- element = $ff.element_by_xpath("//img[contains(@name , 'circ')]")
50
- assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
48
+ element = browser.element_by_xpath("//img[@name='circle']")
49
+ assert_class(element, 'Image')
50
+ element = browser.element_by_xpath("//img[contains(@name , 'circ')]")
51
+ assert_class(element, 'Image')
51
52
  # TODO: This should return null if object is not there.
52
- #element = $ff.element_by_xpath("//img[@id='missing_id']")
53
+ #element = browser.element_by_xpath("//img[@id='missing_id']")
53
54
  #assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
54
- element = $ff.element_by_xpath("//img[@id='square']")
55
- assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
56
- element = $ff.element_by_xpath("//img[contains(@id, 'squ')]")
57
- assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
58
- element = $ff.element_by_xpath("//img[contains(@src , 'triangle')]")
59
- assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
60
- element = $ff.element_by_xpath("//img[contains(@alt , 'cir')]")
61
- assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
55
+ element = browser.element_by_xpath("//img[@id='square']")
56
+ assert_class(element, 'Image')
57
+ element = browser.element_by_xpath("//img[contains(@id, 'squ')]")
58
+ assert_class(element, 'Image')
59
+ element = browser.element_by_xpath("//img[contains(@src , 'triangle')]")
60
+ assert_class(element, 'Image')
61
+ element = browser.element_by_xpath("//img[contains(@alt , 'cir')]")
62
+ assert_class(element, 'Image')
62
63
  # TODO: This should return null if object is not there.
63
- #element = $ff.element_by_xpath("//img[contains(@alt , 'tri')]")
64
+ #element = browser.element_by_xpath("//img[contains(@alt , 'tri')]")
64
65
  #assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
65
66
  end
66
67
 
67
68
  def test_image_click
68
- assert_raises(UnknownObjectException ) { $ff.image(:xpath , "//img[@name='no_image_with_this']").click }
69
- assert_raises(UnknownObjectException ) { $ff.image(:xpath , "//img[@id='no_image_with_this']").click }
70
- assert_raises(UnknownObjectException ) { $ff.image(:xpath , "//img[@src='no_image_with_this']").click}
71
- assert_raises(UnknownObjectException ) { $ff.image(:xpath , "//img[@alt='no_image_with_this']").click}
69
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").click }
70
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").click }
71
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").click}
72
+ assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']").click}
72
73
 
73
74
  # test for bug 1882
74
- $ff.text_field(:name , "text1").clear
75
- $ff.button(:value , /Pos/ ).click
76
- assert_equal('clicked' , $ff.text_field(:name , "text1" ).value )
75
+ browser.text_field(:name , "text1").clear
76
+ browser.button(:value , /Pos/ ).click
77
+ assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
77
78
 
78
79
 
79
80
  # test for disabled button. Click the button to make it disabled
80
- $ff.button(:name , 'disable_img').click
81
- assert( $ff.image(:name , 'disabler_test').disabled )
81
+ browser.button(:name , 'disable_img').click
82
+ assert( browser.image(:name , 'disabler_test').disabled )
82
83
 
83
84
  # Click button again to make it enabled.
84
- $ff.button(:name , 'disable_img').click
85
- assert( ! $ff.image(:name , 'disabler_test').disabled )
85
+ browser.button(:name , 'disable_img').click
86
+ assert( ! browser.image(:name , 'disabler_test').disabled )
86
87
 
87
- $ff.image(:src, /button/).click
88
- assert($ff.text.include?("PASS") )
88
+ browser.image(:src, /button/).click
89
+ assert(browser.text.include?("PASS") )
89
90
 
90
91
  end
91
92
 
92
93
 
93
94
  # TODO: Need to see alternative for this in Mozilla
94
95
  #def test_imageHasLoaded
95
- # assert_raises(UnknownObjectException ) { $ff.image(:xpath , "//img[@name='no_image_with_this']").hasLoaded? }
96
- # assert_raises(UnknownObjectException ) { $ff.image(:xpath , "//img[@id='no_image_with_this']").hasLoaded? }
97
- # assert_raises(UnknownObjectException ) { $ff.image(:xpath , "//img[@src='no_image_with_this']").hasLoaded? }
98
- # assert_raises(UnknownObjectException ) { $ff.image(:xpath , "//img[@alt='no_image_with_this']").hasLoaded? }
96
+ # assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").hasLoaded? }
97
+ # assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").hasLoaded? }
98
+ # assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").hasLoaded? }
99
+ # assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']").hasLoaded? }
99
100
  #
100
- # assert_false( $ff.image(:xpath , "//img[@name='themissingimage']").hasLoaded? )
101
- # assert( $ff.image(:xpath , "//img[@name='circle']").hasLoaded? )
101
+ # assert_false( browser.image(:xpath , "//img[@name='themissingimage']").hasLoaded? )
102
+ # assert( browser.image(:xpath , "//img[@name='circle']").hasLoaded? )
102
103
  #
103
- # assert( $ff.image(:xpath , "//img[@alt='circle']").hasLoaded? )
104
- # # assert( $ff.image(:alt, /cir/ ).hasLoaded? )
104
+ # assert( browser.image(:xpath , "//img[@alt='circle']").hasLoaded? )
105
+ # # assert( browser.image(:alt, /cir/ ).hasLoaded? )
105
106
  #end
106
107
 
107
108
  def test_image_properties
108
109
  # TODO: Need to see alternative for this in Mozilla
109
- #assert_raises(UnknownObjectException ) { $ff.image(:xpath , "//img[@name='no_image_with_this']").hasLoaded? }
110
- #assert_raises(UnknownObjectException ) { $ff.image(:xpath , "//img[@id='no_image_with_this']").hasLoaded? }
111
- #assert_raises(UnknownObjectException ) { $ff.image(:xpath , "//img[@src='no_image_with_this']").hasLoaded? }
110
+ #assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").hasLoaded? }
111
+ #assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").hasLoaded? }
112
+ #assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").hasLoaded? }
112
113
 
113
114
  # to string tests -- output should be verified!
114
- puts $ff.image(:xpath , "//img[@name='circle']").to_s
115
+ puts browser.image(:xpath , "//img[@name='circle']").to_s
115
116
  end
116
117
 
117
118
  end
@@ -1,6 +1,6 @@
1
1
  # unit tests for IOString in iostring.rb
2
2
 
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
4
  require 'unittests/iostring'
5
5
  require 'test/unit'
6
6
 
@@ -1,71 +1,75 @@
1
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
2
  require 'unittests/setup'
3
3
 
4
4
  class TC_JavaScript_Test < Test::Unit::TestCase
5
- include FireWatir
5
+
6
6
  # include FireWatir::Dialog
7
7
 
8
8
  def setup
9
- $ff.goto($htmlRoot + 'JavascriptClick.html')
9
+ goto_page 'JavascriptClick.html'
10
10
  end
11
11
 
12
+ tag_method :test_alert, :fails_on_ie
12
13
  def test_alert
13
- #$ff.button(:id, "btnAlert").click_no_wait()
14
+ #browser.button(:id, "btnAlert").click_no_wait()
14
15
 
15
- #$ff.click_jspopup_button("OK")
16
- $ff.startClicker("ok", 1, '', "Press OK")
17
- $ff.button(:id, "btnAlert").click
16
+ #browser.click_jspopup_button("OK")
17
+ browser.startClicker("ok", 1, '', "Press OK")
18
+ browser.button(:id, "btnAlert").click
18
19
 
19
- assert_equal($ff.text_field(:id, "testResult").value , "You pressed the Alert button!")
20
- assert_equal("Press OK", $ff.get_popup_text)
20
+ assert_equal(browser.text_field(:id, "testResult").value , "You pressed the Alert button!")
21
+ assert_equal("Press OK", browser.get_popup_text)
21
22
 
22
- $ff.startClicker("ok")
23
- $ff.button(:id, "btnAlert").click
23
+ browser.startClicker("ok")
24
+ browser.button(:id, "btnAlert").click
24
25
 
25
- assert_equal($ff.text_field(:id, "testResult").value , "You pressed the Alert button!")
26
- assert_equal("Press OK", $ff.get_popup_text)
26
+ assert_equal(browser.text_field(:id, "testResult").value , "You pressed the Alert button!")
27
+ assert_equal("Press OK", browser.get_popup_text)
27
28
  end
28
29
 
30
+ tag_method :test_confirm_ok, :fails_on_ie
29
31
  def test_confirm_ok
30
- #$ff.button(:id, "btnConfirm").click_no_wait()
32
+ #browser.button(:id, "btnConfirm").click_no_wait()
31
33
 
32
- #$ff.click_jspopup_button("OK")
33
- $ff.startClicker("ok", 1, '', "Press a button")
34
- $ff.button(:id, "btnConfirm").click
34
+ #browser.click_jspopup_button("OK")
35
+ browser.startClicker("ok", 1, '', "Press a button")
36
+ browser.button(:id, "btnConfirm").click
35
37
 
36
- assert_equal($ff.text_field(:id, "testResult").value , "You pressed the Confirm and OK button!")
37
- assert_equal("Press a button", $ff.get_popup_text)
38
+ assert_equal(browser.text_field(:id, "testResult").value , "You pressed the Confirm and OK button!")
39
+ assert_equal("Press a button", browser.get_popup_text)
38
40
 
39
- $ff.startClicker("ok")
40
- $ff.button(:id, "btnConfirm").click
41
+ browser.startClicker("ok")
42
+ browser.button(:id, "btnConfirm").click
41
43
 
42
- assert_equal($ff.text_field(:id, "testResult").value , "You pressed the Confirm and OK button!")
43
- assert_equal("Press a button", $ff.get_popup_text)
44
+ assert_equal(browser.text_field(:id, "testResult").value , "You pressed the Confirm and OK button!")
45
+ assert_equal("Press a button", browser.get_popup_text)
44
46
  end
45
47
 
48
+ tag_method :test_confirm_cancel, :fails_on_ie
46
49
  def test_confirm_cancel
47
- #$ff.button(:id, "btnConfirm").click_no_wait()
50
+ #browser.button(:id, "btnConfirm").click_no_wait()
48
51
 
49
- #$ff.click_jspopup_button("Cancel")
50
- $ff.startClicker("cancel", 1, '', "Press a button")
51
- $ff.button(:id, "btnConfirm").click
52
+ #browser.click_jspopup_button("Cancel")
53
+ browser.startClicker("cancel", 1, '', "Press a button")
54
+ browser.button(:id, "btnConfirm").click
52
55
 
53
- assert_equal($ff.text_field(:id, "testResult").value, "You pressed the Confirm and Cancel button!")
54
- assert_equal("Press a button", $ff.get_popup_text)
56
+ assert_equal(browser.text_field(:id, "testResult").value, "You pressed the Confirm and Cancel button!")
57
+ assert_equal("Press a button", browser.get_popup_text)
55
58
 
56
- $ff.startClicker("cancel")
57
- $ff.button(:id, "btnConfirm").click
59
+ browser.startClicker("cancel")
60
+ browser.button(:id, "btnConfirm").click
58
61
 
59
- assert_equal($ff.text_field(:id, "testResult").value, "You pressed the Confirm and Cancel button!")
60
- assert_equal("Press a button", $ff.get_popup_text)
62
+ assert_equal(browser.text_field(:id, "testResult").value, "You pressed the Confirm and Cancel button!")
63
+ assert_equal("Press a button", browser.get_popup_text)
61
64
  end
62
65
 
66
+ tag_method :test_ok_selectbox, :fails_on_ie
63
67
  def test_ok_selectbox
64
- $ff.goto($htmlRoot + "selectboxes1.html")
65
- $ff.startClicker("ok")
66
- $ff.select_list(:id , "selectbox_5").select_value(/2/)
68
+ goto_page("selectboxes1.html")
69
+ browser.startClicker("ok")
70
+ browser.select_list(:id , "selectbox_5").select_value(/2/)
67
71
 
68
- assert_equal($ff.text_field(:id, "txtAlert").value , "You pressed OK button")
69
- assert_equal("Press OK", $ff.get_popup_text)
72
+ assert_equal(browser.text_field(:id, "txtAlert").value , "You pressed OK button")
73
+ assert_equal("Press OK", browser.get_popup_text)
70
74
  end
71
75
  end
@@ -1,169 +1,170 @@
1
1
  # feature tests for Links
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_Links < Test::Unit::TestCase
8
- include FireWatir
8
+
9
9
 
10
10
  def setup()
11
- $ff.goto($htmlRoot + "links1.html")
11
+ goto_page("links1.html")
12
12
  end
13
13
 
14
14
  def test_new_link_exists
15
- assert($ff.link(:text, "test1").exists?)
16
- assert($ff.link(:text, /TEST/i).exists?)
15
+ assert(browser.link(:text, "test1").exists?)
16
+ assert(browser.link(:text, /TEST/i).exists?)
17
17
  end
18
18
 
19
19
  # In current implementation, method_missing catches all the methods that are not defined
20
20
  # for the element. So there is no way to find out about missinwayoffindingobject exp.
21
+ tag_method :test_bad_attribute, :fails_on_ie
21
22
  def test_bad_attribute
22
- assert_raises(UnknownObjectException) { $ff.link(:bad_attribute, 199).click }
23
+ assert_raises(UnknownObjectException) { browser.link(:bad_attribute, 199).click }
23
24
  begin
24
- $ff.link(:bad_attribute, 199).click
25
+ browser.link(:bad_attribute, 199).click
25
26
  rescue UnknownObjectException => e
26
- assert_equal "Unable to locate object, using bad_attribute and 199", e.to_s
27
+ assert_equal "Unable to locate element, using :bad_attribute, 199", e.to_s
27
28
  end
28
29
  end
29
30
 
30
31
  def test_missing_links_dont_exist
31
- assert_false($ff.link(:text, "missing").exists?)
32
- assert_false($ff.link(:text, /miss/).exists?)
32
+ assert_false(browser.link(:text, "missing").exists?)
33
+ assert_false(browser.link(:text, /miss/).exists?)
33
34
  end
34
35
 
35
36
  def test_link_Exists
36
- assert($ff.link(:text, "test1").exists?)
37
- assert($ff.link(:text, /TEST/i).exists?)
38
- assert_false($ff.link(:text, "missing").exists?)
39
- assert_false($ff.link(:text, /miss/).exists?)
37
+ assert(browser.link(:text, "test1").exists?)
38
+ assert(browser.link(:text, /TEST/i).exists?)
39
+ assert_false(browser.link(:text, "missing").exists?)
40
+ assert_false(browser.link(:text, /miss/).exists?)
40
41
 
41
42
  # this assert we have to build up the path
42
43
  # this is what it looks like if you do a to_s on the link file:///C:/watir_bonus/unitTests/html/links1.HTML
43
44
  # but what we get back from $htmlRoot is a mixed case, so its almost impossible for use to test this correctly
44
- # assert($ff.link(:url,'file:///C:/watir_bonus/unitTests/html/links1.HTML' ).exists?)
45
+ # assert(browser.link(:url,'file:///C:/watir_bonus/unitTests/html/links1.HTML' ).exists?)
45
46
 
46
- assert($ff.link(:url, /link_pass.html/).exists?)
47
- assert_false($ff.link(:url, "alsomissing.html").exists?)
47
+ assert(browser.link(:url, /link_pass.html/).exists?)
48
+ assert_false(browser.link(:url, "alsomissing.html").exists?)
48
49
 
49
- assert($ff.link(:id, "link_id").exists?)
50
- assert_false($ff.link(:id, "alsomissing").exists?)
50
+ assert(browser.link(:id, "link_id").exists?)
51
+ assert_false(browser.link(:id, "alsomissing").exists?)
51
52
 
52
- assert($ff.link(:id, /_id/).exists?)
53
- assert_false($ff.link(:id, /alsomissing/).exists?)
53
+ assert(browser.link(:id, /_id/).exists?)
54
+ assert_false(browser.link(:id, /alsomissing/).exists?)
54
55
 
55
- assert($ff.link(:name, "link_name").exists?)
56
- assert_false($ff.link(:name, "alsomissing").exists?)
56
+ assert(browser.link(:name, "link_name").exists?)
57
+ assert_false(browser.link(:name, "alsomissing").exists?)
57
58
 
58
- assert($ff.link(:name, /_n/).exists?)
59
- assert_false($ff.link(:name, /missing/).exists?)
59
+ assert(browser.link(:name, /_n/).exists?)
60
+ assert_false(browser.link(:name, /missing/).exists?)
60
61
 
61
- assert($ff.link(:title, /ti/).exists?)
62
- assert($ff.link(:title, "link_title").exists?)
62
+ assert(browser.link(:title, /ti/).exists?)
63
+ assert(browser.link(:title, "link_title").exists?)
63
64
 
64
- assert_false($ff.link(:title, /missing/).exists?)
65
+ assert_false(browser.link(:title, /missing/).exists?)
65
66
 
66
- assert($ff.link(:url, /_pass/).exists?)
67
- assert_false($ff.link(:url, /dont_exist/).exists?)
67
+ assert(browser.link(:url, /_pass/).exists?)
68
+ assert_false(browser.link(:url, /dont_exist/).exists?)
68
69
  end
69
70
 
70
71
  def test_link_click
71
- $ff.link(:text, "test1").click
72
- assert( $ff.text.include?("Links2-Pass") )
72
+ browser.link(:text, "test1").click
73
+ assert( browser.text.include?("Links2-Pass") )
73
74
  end
74
75
  def test_link2_click
75
- $ff.link(:url, /link_pass.html/).click
76
- assert( $ff.text.include?("Links3-Pass") )
76
+ browser.link(:url, /link_pass.html/).click
77
+ assert( browser.text.include?("Links3-Pass") )
77
78
  end
78
79
  def test_link3_click
79
- $ff.link(:index, 1).click
80
- assert( $ff.text.include?("Links2-Pass") )
80
+ browser.link(:index, 1).click
81
+ assert( browser.text.include?("Links2-Pass") )
81
82
  end
82
83
  def test_link4_click
83
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).click }
84
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).click }
84
85
  end
85
86
 
86
87
  def test_link_properties
87
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).href }
88
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).value}
89
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).text }
90
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).name }
91
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).id }
92
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).disabled }
93
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).type }
94
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).class_name }
95
-
96
- assert_match( /links2/ ,$ff.link(:index, 1).href )
97
- assert_equal( "" , $ff.link(:index, 1).value)
98
- assert_equal( "test1" , $ff.link(:index, 1).text )
99
- assert_equal( "" , $ff.link(:index, 1).name )
100
- assert_equal( "" , $ff.link(:index, 1).id )
101
- #assert_equal( false , $ff.link(:index, 1).disabled )
102
- assert_equal( "" , $ff.link(:index, 1).class_name)
103
- assert_equal( "link_class_1" , $ff.link(:index, 2).class_name)
104
-
105
- assert_equal( "link_id" , $ff.link(:index, 6).id )
106
- assert_equal( "link_name" , $ff.link(:index, 7).name )
107
-
108
- assert_equal( "" , $ff.link(:index, 7).title)
109
-
110
- assert_equal( "link_title" , $ff.link(:index, 8).title)
88
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).href }
89
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).value}
90
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).text }
91
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).name }
92
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).id }
93
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).disabled }
94
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).type }
95
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).class_name }
96
+
97
+ assert_match( /links2/ ,browser.link(:index, 1).href )
98
+ assert_equal( "" , browser.link(:index, 1).value)
99
+ assert_equal( "test1" , browser.link(:index, 1).text )
100
+ assert_equal( "" , browser.link(:index, 1).name )
101
+ assert_equal( "" , browser.link(:index, 1).id )
102
+ assert_equal( false , browser.link(:index, 1).disabled )
103
+ assert_equal( "" , browser.link(:index, 1).class_name)
104
+ assert_equal( "link_class_1" , browser.link(:index, 2).class_name)
105
+
106
+ assert_equal( "link_id" , browser.link(:index, 6).id )
107
+ assert_equal( "link_name" , browser.link(:index, 7).name )
108
+
109
+ assert_equal( "" , browser.link(:index, 7).title)
110
+
111
+ assert_equal( "link_title" , browser.link(:index, 8).title)
111
112
  end
112
113
 
113
114
  def test_text_attribute
114
- arr1 = $ff.link(:text, "nameDelet").to_s
115
- arr2 = $ff.link(:text, /Delet/).to_s
115
+ arr1 = browser.link(:text, "nameDelet").to_s
116
+ arr2 = browser.link(:text, /Delet/).to_s
116
117
  assert_equal(arr1, arr2)
117
118
 
118
119
  end
119
120
 
120
121
  def test_link_iterator
121
- assert_equal(11, $ff.links.length )
122
- assert_equal("Link Using a name" , $ff.links[7].text)
122
+ assert_equal(11, browser.links.length )
123
+ assert_equal("Link Using a name" , browser.links[7].text)
123
124
 
124
125
  index = 1
125
- $ff.links.each do |link|
126
- assert_equal( $ff.link(:index, index).href , link.href )
127
- assert_equal( $ff.link(:index, index).id , link.id )
128
- assert_equal( $ff.link(:index, index).name , link.name )
129
- assert_equal( $ff.link(:index, index).innerText , link.text )
126
+ browser.links.each do |link|
127
+ assert_equal( browser.link(:index, index).href , link.href )
128
+ assert_equal( browser.link(:index, index).id , link.id )
129
+ assert_equal( browser.link(:index, index).name , link.name )
130
+ assert_equal( browser.link(:index, index).innerText , link.text )
130
131
  index+=1
131
132
  end
132
133
  end
133
134
 
134
135
  def test_div_xml_bug
135
- $ff.goto($htmlRoot + "div_xml.html")
136
- assert_nothing_raised {$ff.link(:text, 'Create').exists? }
136
+ goto_page("div_xml.html")
137
+ assert_nothing_raised {browser.link(:text, 'Create').exists? }
137
138
  end
138
139
  def test_link_to_s
139
- puts $ff.link(:id,"linktos").to_s
140
+ puts browser.link(:id,"linktos").to_s
140
141
  end
141
142
  end
142
143
 
143
144
  class TC_Frame_Links < Test::Unit::TestCase
144
- include FireWatir
145
+
145
146
 
146
147
  def setup()
147
- $ff.goto($htmlRoot + "frame_links.html")
148
+ goto_page("frame_links.html")
148
149
  end
149
150
 
150
151
  def test_new_frame_link_exists
151
- assert($ff.frame("buttonFrame").link(:text, "test1").exists?)
152
+ assert(browser.frame("buttonFrame").link(:text, "test1").exists?)
152
153
  end
153
154
  def test_missing_frame_links_dont_exist
154
- assert_false($ff.frame("buttonFrame").link(:text, "missing").exists?)
155
- assert_raise(UnknownFrameException, "UnknownFrameException was supposed to be thrown"){$ff.frame("missing").link(:text, "test1").exists?}
155
+ assert_false(browser.frame("buttonFrame").link(:text, "missing").exists?)
156
+ assert_raise(UnknownFrameException, "UnknownFrameException was supposed to be thrown"){browser.frame("missing").link(:text, "test1").exists?}
156
157
  end
157
158
 
158
159
  def test_links_in_frames
159
- assert($ff.frame("buttonFrame").link(:text, "test1").exists?)
160
- assert_false($ff.frame("buttonFrame").link(:text, "missing").exists?)
160
+ assert(browser.frame("buttonFrame").link(:text, "test1").exists?)
161
+ assert_false(browser.frame("buttonFrame").link(:text, "missing").exists?)
161
162
 
162
- assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ff.frame("buttonFrame").link(:index, 199).href }
163
- assert_match(/links2/, $ff.frame("buttonFrame").link(:index, 1).href)
163
+ assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.frame("buttonFrame").link(:index, 199).href }
164
+ assert_match(/links2/, browser.frame("buttonFrame").link(:index, 1).href)
164
165
 
165
166
  count =0
166
- $ff.frame("buttonFrame").links.each do |l|
167
+ browser.frame("buttonFrame").links.each do |l|
167
168
  count+=1
168
169
  end
169
170
 
@@ -172,13 +173,14 @@ class TC_Frame_Links < Test::Unit::TestCase
172
173
  end
173
174
 
174
175
  class TC_Links_Display < Test::Unit::TestCase
175
- include FireWatir
176
+
176
177
  include MockStdoutTestCase
177
178
 
179
+ tag_method :test_showLinks, :fails_on_ie
178
180
  def test_showLinks
179
- $ff.goto($htmlRoot + "links1.html")
181
+ goto_page("links1.html")
180
182
  $stdout = @mockout
181
- $ff.showLinks
183
+ browser.showLinks
182
184
  assert_equal(<<END_OF_MESSAGE, @mockout)
183
185
  There are 11 links
184
186
  link: name: