Skip to content
Browse files

fix tests

  • Loading branch information...
1 parent 596ca4a commit 6297e110f3e56a46baeefed013a34d9c506737a4 @jarmo jarmo committed Mar 12, 2012
Showing with 8 additions and 51 deletions.
  1. +8 −51 watir/unittests/links_test.rb
View
59 watir/unittests/links_test.rb
@@ -13,12 +13,10 @@ def setup
tag_method :test_bad_attribute, :fails_on_firefox
def test_bad_attribute
- assert_raises(MissingWayOfFindingObjectException) { browser.link(:bad_attribute, 199).click }
- begin
- browser.link(:bad_attribute, 199).click
- rescue MissingWayOfFindingObjectException => e
- assert_equal "bad_attribute is an unknown way of finding a <A> element (199)", e.to_s
- end
+ browser.link(:bad_attribute, 199).click
+ fail "#click should have raised an Exception!"
+ rescue MissingWayOfFindingObjectException => e
+ assert_equal "bad_attribute is an unknown way of finding a <a> element (199)", e.to_s
end
def xtest_missing_links_dont_exist
@@ -46,12 +44,6 @@ def test_link_Exists
assert(browser.link(:id, /_id/).exists?)
assert_false(browser.link(:id, /alsomissing/).exists?)
- assert(browser.link(:name, "link_name").exists?)
- assert_false(browser.link(:name, "alsomissing").exists?)
-
- assert(browser.link(:name, /_n/).exists?)
- assert_false(browser.link(:name, /missing/).exists?)
-
assert(browser.link(:title, /ti/).exists?)
assert(browser.link(:title, "link_title").exists?)
@@ -79,25 +71,17 @@ def test_link4_click
def test_link_properties
assert_raises(UnknownObjectException) { browser.link(:index, 199).href }
- assert_raises(UnknownObjectException) { browser.link(:index, 199).value}
- assert_raises(UnknownObjectException) { browser.link(:index, 199).innerText }
- assert_raises(UnknownObjectException) { browser.link(:index, 199).name }
+ assert_raises(UnknownObjectException) { browser.link(:index, 199).text }
assert_raises(UnknownObjectException) { browser.link(:index, 199).id }
- assert_raises(UnknownObjectException) { browser.link(:index, 199).disabled }
- assert_raises(UnknownObjectException) { browser.link(:index, 199).type }
assert_raises(UnknownObjectException) { browser.link(:index, 199).class_name }
assert_match(/links2/ ,browser.link(:index, 0).href )
- assert_equal("" , browser.link(:index, 0).value)
- assert_equal("test1" , browser.link(:index, 0).innerText )
- assert_equal("" , browser.link(:index, 0).name )
+ assert_equal("test1" , browser.link(:index, 0).text )
assert_equal("" , browser.link(:index, 0).id )
- assert_equal(false , browser.link(:index, 0).disabled )
assert_equal("" , browser.link(:index, 0).class_name)
assert_equal("link_class_1" , browser.link(:index, 1).class_name)
assert_equal("link_id" , browser.link(:index, 5).id )
- assert_equal("link_name" , browser.link(:index, 6).name )
assert_equal("" , browser.link(:index, 6).title)
@@ -106,14 +90,13 @@ def test_link_properties
def test_link_iterator
assert_equal(9, browser.links.length )
- assert_equal("Link Using a name" , browser.links[6].innerText)
+ assert_equal("Link Using a name" , browser.links[6].text)
index = 0
browser.links.each do |link|
assert_equal(browser.link(:index, index).href , link.href )
assert_equal(browser.link(:index, index).id , link.id )
- assert_equal(browser.link(:index, index).name , link.name )
- assert_equal(browser.link(:index, index).innerText , link.innerText )
+ assert_equal(browser.link(:index, index).text , link.text )
index+=1
end
end
@@ -146,29 +129,3 @@ def test_links_in_frames
assert_equal( 9 , count)
end
end
-
-class TC_showlinks < Test::Unit::TestCase
- tags :fails_on_firefox
- include CaptureIOHelper
-
- def test_showLinks
- goto_page "links1.html"
- actual = capture_stdout { browser.showLinks }
- expected = [/^index name +id +href + text\/src$/,
- get_path_regex(1, "links2.html", "test1"),
- get_path_regex(2, "link_pass.html", "test1"),
- get_path_regex(3, "pass3.html", " / file:///#{$myDir.downcase}/html/images/button.jpg"),
- get_path_regex(4, "textarea.html", "new window"),
- get_path_regex(5, "textarea.html", "new window"),
- get_path_regex(6, "links1.html", "link using an id", "link_id"),
- get_path_regex(7, "links1.html", "link using a name", "link_name"),
- get_path_regex(8, "links1.html", "link using a title"),
- get_path_regex(9, "pass.html", "image and a text link / file:///#{$myDir.downcase}/html/images/triangle.jpg")]
- items = actual.split(/\n/).collect {|s| CGI.unescape(s.downcase.strip)}
- expected.each_with_index{|regex, x| assert_match(regex, items[x])}
- end
-
- def get_path_regex(idx, name, inner, nameid="")
- Regexp.new("^#{idx} +#{nameid} +file:///#{$myDir.downcase}/html/#{name} *#{inner}$")
- end
-end

0 comments on commit 6297e11

Please sign in to comment.
Something went wrong with that request. Please try again.