Let's look at this code step by step:
>while (true)
First of all, whatever it does, you apparently intend to do it forever. Do
you really intend that? What criterion or line of code would get you out of
this infinite loop? If you're /depending/ on a crash, that might do it.
> if($ie.frame("mainFrame").table(:id, 'nav-menu').exists? )
> puts "I found the table"
> end
Next, if you found the table, you announce that you found the table; then
you drop out of the conditional and proceed to the next steps. If you
/didn't/ find the table, you drop out of the conditional, and proceed to the
next steps. Other than printing a message to the screen, whether you find
what you're looking for or not, /the code tries to do exactly the same
thing/.
> searchExists=0
> i=3
i is a magic number here. It has the value 3, and yet has nothing else
associated with it--certainly no indication of what it's for, or why it's 3.
Why IS it 3?
> t = $ie.frame("mainFrame").table(:id, 'nav-menu')
If you find a table with an id attribute of 'nav-menu', you do something.
If you don't find such a table, you should get a nil on the .each method,
without an apparent error handler or alternative path of action. Are you
sure you want that to happen?
> t.each do |row|
> puts "iterating #{i} row"
Since i is equal to 3, this will always report that you're on row 3, /even
when you're not on row 3/. Might you be deleting something inadvertently
because you're not where you think you are?
> #puts "search Name = #{searchName}"
Where does the searchName value come from? Is it a local variable that
you've assigned somewhere else?
> #puts "11th Column = #{row[11].text}"
> #puts "3rd Column = #{row[3].text}"
Let's assume that we're the first time through your rows.each loop. This
next line should give you the text in the 8th column. Is that what's
happening?
> puts "8th Column = #{row[8].text}"
> if (row[8].text == "deschedule" )
> puts "This is scheduled"
> # i = i + 1
> end
Let's continue assume that we're on the first time through your rows.each
loop.
> i = i + 4
The variable i, mysteriously 3, is now mysteriously 7. Why?
> if (row[3].text =~ /#{searchName}/ )
Still assuming that we're on the first trip through the loop, the local
variable that you've assigned somewhere else will now be matched to the
third column in the first row.
> searchExist=1
> puts "Search Name = #{row[3].text}"
> puts "11th Column = #{row[11].text}"
> p row[11].class
> p row[11].methods
> row[11].click
STILL assuming that we're on the first trip through the loop, this link will
click on the the eleventh column, which is the same as clicking the "delete"
link, if I read table.html correctly.
> $ie.frame("mainFrame").link(:index, i).flash
> $ie.frame("mainFrame").link(:index, i).flash
On the first trip through the loop, these lines will flash the seventh link
in the mainFrame frame, twice. Does that happen? On the next trip through
the loop, these lines will flash the eleventh link (see the i = i + 4 line
above); the third trip, the they'll flash the 15th link, and so on.
> $ie.frame("mainFrame").link(:index, i).click
This will click on the seventh (eleventh, fifteenth...) links...
> break;
...except it won't because you only go through the each loop once.
> end
> end
I added an extra end, because the "while(true)" in the snippet you provided
was unbalanced.
I think you might want to refactor this code.
---Michael B.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Manish Sapariya
Sent: February 18, 2006 8:41 AM
To: [email protected]
Subject: Re: [Wtr-general] how to access links in table cells
Hi,
Please find attached html and my watir code.
I could get the flash working on the link, but
when i click the link it actually deletes other entries.
Is there a better way than what I am doing?
Thanks and Regards,
Manish
On 02/17/2006 10:10 AM, Bret Pettichord wrote:
> Please provide html and code.
>
> On 2/16/06, *Manish Sapariya* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> Hi,
> I have a table, which has few columns with simple
> text and few columns with links.
>
> I want to do a search on text columns, and click in
> the link for one of the column for a given row.
>
> I can search the row successfully using text, but
> I can't click on that row.
>
> When I check the class of the row[i].class, it
> shows as TableCell.
> How do I click link object in that particular
> cell.
>
> THanks for help.
> REgards,
> Manish
>
> _______________________________________________
> Wtr-general mailing list
> [email protected] <mailto:[email protected]>
> http://rubyforge.org/mailman/listinfo/wtr-general
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Wtr-general mailing list
>[email protected]
>http://rubyforge.org/mailman/listinfo/wtr-general
>
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general