Skip to content

Instantly share code, notes, and snippets.

@ragnard
Created January 12, 2012 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ragnard/1599715 to your computer and use it in GitHub Desktop.
Save ragnard/1599715 to your computer and use it in GitHub Desktop.
:class locator issue
1.9.2p290 :001 > require 'watir-webdriver'
=> true
1.9.2p290 :002 > browser = Watir::Browser.new :firefox
=> #<Watir::Browser:0x27fd323015c1b386 url="about:blank" title="">
1.9.2p290 :003 > browser.goto "file:///page.html"
=> "file:///Users/ragge/tmp/page.html"
1.9.2p290 :006 > browser.element(:class => "b").text
=> "Blahonga"
1.9.2p290 :008 > browser.div(:class => "b").text
Watir::Exception::UnknownObjectException: unable to locate element, using {:class=>"b", :tag_name=>"div"}
from /Users/ragge/.rvm/gems/ruby-1.9.2-p290/gems/watir-webdriver-0.4.1/lib/watir-webdriver/elements/element.rb:262:in `assert_exists'
from /Users/ragge/.rvm/gems/ruby-1.9.2-p290/gems/watir-webdriver-0.4.1/lib/watir-webdriver/elements/element.rb:64:in `text'
from (irb):8
from /Users/ragge/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'
1.9.2p290 :010 > browser.div(:class => "a b c").text
=> "Blahonga"
<html>
<div class="a b c">Blahonga</div>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment