Question from WATIR

hi,

please look at the code below

$browser.table(:id,‘something’).rows.each do |row|
$browser.button(:id,‘Next’).click #it will bring to next page
$browser.button(:id,‘Back’).click #again bring to the first page
row.click
end

my problem is this ‘row.click’ is not working here since I moved to next
page and coming back the same page. How would I resolve this problem?

RAJ

It’s hard to tell without knowing why it’s not working. What error
message
did you get?
Also, we need to know what web pages you’re testing against, either the
url or the source code.
Without those I’m guessing you have to wait for the page to fully load
before you can click the element.

“ruby-talk” [email protected] wrote on 02/21/2014
06:32:39
AM:

but can you please tell me when we are inside the b.table.rows.each
loop, Can we move to another screen, and come back to same page and then
can we able to use the variable ‘row.click’ And I will post my error
also,

unknown property or method `click’
HRESULT error code:0x80070005

And I am sure this error occur because I moved to another screen and
then I came back.

RAJ

I haven’t tried it, and I mainly use watir-webdriver & selenium.
However, I would expect it to work. The ‘row’ object should still be
correct.

The error does not look like its having a problem finding the row. I
would
expect an error like ‘unable to locate . . .’ or ’ unknown method…
for
nil’ if the row couldn’t be found or if ‘row’ had been reset. It looks
like ‘row’ is an object that doesn’t have a click method even if it
found
the row on the page.

Does it work if the ‘next’ & ‘back’ lines are commented out?

“ruby-talk” [email protected] wrote on 02/21/2014
07:31:55
AM:

From: Raja gopalan [email protected]
To: [email protected]
Date: 02/21/2014 07:32 AM
Subject: Re: question from WATIR
Sent by: “ruby-talk” [email protected]

but can you please tell me when we are inside the b.table.rows.each
loop, Can we move to another screen, and come back to same page and then

unknown wrote in post #1137470:

Does it work if the ‘next’ & ‘back’ lines are commented out?

yes yes, It’s working. Even I was also expecting the same error like

undefined method `click’ for nil:NilClass (NoMethodError) But it was
not, row is available there, because I printed the class of row like
“puts row.class”, it’s printing the class: Watir::TableRow.

RAJ.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs