Sha256: bb1316ad98ab0c719954ed2cb13bb32e5885da0ece98e89efafbf917f2ce2c56

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

# feature tests for Links
# revision: $Revision: 975 $

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
require 'unittests/setup'

class TC_Links_XPath < Test::Unit::TestCase
  include Watir
  
  def setup
    $ie.goto($htmlRoot + "links1.html")
  end
  
  def test_link_exists
    assert($ie.link(:xpath, "//a[contains(.,'test1')]/").exists?)
    assert($ie.link(:xpath, "//a[contains(., /TEST/i)]/").exists?)   
    assert(!$ie.link(:xpath, "//a[contains(.,'missing')]/").exists?)
    
    assert(!$ie.link(:xpath, "//a[@url='alsomissing.html']/").exists?)
    
    assert($ie.link(:xpath, "//a[@id='link_id']/").exists?)
    assert(!$ie.link(:xpath, "//a[@id='alsomissing']/").exists?)
    
    assert($ie.link(:xpath, "//a[@name='link_name']/").exists?)
    assert(!$ie.link(:xpath, "//a[@name='alsomissing']/").exists?)
    assert($ie.link(:xpath, "//a[@title='link_title']/").exists?)
  end
  
  def test_link_click
    $ie.link(:xpath, "//a[contains(.,'test1')]/").click
    assert($ie.text.include?("Links2-Pass"))
  end
  
  def test_link_with_text_call
    $ie.link(:xpath, "//a[text()='test1']").click
    assert($ie.text.include?("Links2-Pass"))
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
watir-1.5.2 unittests/links_xpath_test.rb
watir-1.5.3 unittests/links_xpath_test.rb
watir-1.5.4 unittests/links_xpath_test.rb