[wtr-general] checkbox question

2011-04-07 Thread bryan
Hi,
Newbie with selenium with watir webdriver...

I have the following code( I have omitted code I suppose is less
likely to be relevant):

label = $browser.label(:text, what)
  if label.exists?
if label.for.blank?
  puts no 'for' attribute, will try first content if $DEBUG
  begin
puts trying checkbox
return label.checkbox(:index, 1)
  rescue
...

And content like this

labelinput type=checkbox autocomplete=off name=topiccode
value=2Regnskab/label

When I look for the label Regnskab I find it, but when I run the
label.checkbox(:index, 1) I get

 And I click Regnskab  #
features/step_definitions/general_navigation.rb:61
  unable to locate element, using
{:index=1, :tag_name=input, :type=checkbox}
(Watir::Exception::UnknownObjectException)

Any particular explanation on this?

In case I can't find a solution on this I was thinking to use xpath -
can someone give me an example of doing the above with xpath in
selenium using watir webdriver?

Thanks,
Bryan Rasmussen



-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] checkbox question

2011-04-07 Thread Jari Bakken
On Thu, Apr 7, 2011 at 1:25 AM, bryan rasmussen.br...@gmail.com wrote:

 When I look for the label Regnskab I find it, but when I run the
 label.checkbox(:index, 1) I get

  And I click Regnskab                                              #
 features/step_definitions/general_navigation.rb:61
      unable to locate element, using
 {:index=1, :tag_name=input, :type=checkbox}
 (Watir::Exception::UnknownObjectException)

 Any particular explanation on this?


I think this is because watir-webdriver is 0-indexed, not 1-indexed
like Watir. That's one of the major changes, you'll find a list of
more here:

  https://github.com/jarib/watir-webdriver/wiki/Comparison-with-Watir-1.X

Jari

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com