Forum: Ruby watir question regarding to Browser.

5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2013-11-06 11:26
hi

I want to gain the control of last opened browser.How would I do that?
For an example

b=browser.windows.last

this is returning the window object but I want IE object thereby I could
able to access function inside WATIR::Browser, So how would I do this?
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2013-11-06 12:03
Try b = browser.windows.last.browser
5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2013-11-06 12:40
hi

It's working perfect, thank you.
5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2013-11-07 06:46
hi  Joel Pearson,


I was using WATIR::IE.attach(:index,1) to attach the browser. Now I am
using       $browser1 = $browser.windows.last.browser and the problem
with this type of attachment is, before the browser is completely
loaded, next operation is performed, For an example,

line 1:$browser1 = $browser.windows.last.browser
line 2:$browser.link(:id,'something').click

Line number 2 is executed before the page loads completely. So it gives
the error of unable to locate the element, Now If use sleep statement in
between line1 and line 2 like below

line 1:$browser1 = $browser.windows.last.browser
sleep 2
line 2:$browser.link(:id,'something').click

it works, But it's not an ideal solution because browser loading time
varies.  The same problem did not occur while I was using
WATIR::IE.attach(:index,1). So could you please tell me how to overcome
this problem?
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2013-11-07 09:57
Wait for the page to load before line 1
5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2013-11-07 10:02
yes that's what I am putting sleep statement in between, but are you
saying someother way?
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2013-11-07 10:16
Depending on your version of Watir, this might work:

$browser.link(:id,'something').when_present.click
5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2013-11-07 15:14
hi thank you.

when_present is working here, But I wrongly typed the code, Actually it
was,

line 1:$browser1 = $browser.windows.last.browser

line 2: parseHTML($browser1.table(:class,'something').html)
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2013-11-07 15:40
parseHTML($browser1.table(:class,'something').when_present.html)
5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2013-11-08 08:15
hi Thank you.
I use your code but still it's not reading. It's ok, I swifted to attach
browser using index now.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.