I observe only one thing that's odd about this.
When I start up IE manually, I'm taken to google.ca (the Canadian version).
The title bar for the window reads "Google - Microsoft Internet Explorer".
I set IE.attach_timeout to 15. I issue this command
ie = Watir::IE.attach(:title, /oogle/)
and the ie object successfully attaches.
This line of code fails to find the same window:
ie = Watir::IE.attach(:title, /Microsoft/)
Watir::Exception::NoMatchingWindowFoundException: Unable to locate a window
with title of (?-mix:Microsoft)
from c:/ruby/lib/ruby/gems/1.8/gems/watir-
1.5.0.934/./watir.rb:1268:in `attach_browser_window'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-
1.5.0.934/./watir.rb:1135:in `attach_init'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-
1.5.0.934/./watir.rb:1128:in `attach'
from (irb):9
from ♥:0
However, it does find the "Microsoft" when I go to Microsoft's site. In
this case, the window is titled "Microsoft Corporation - Microsoft Internet
Explorer".
I would conclude that the " - Microsoft Internet Explorer" is not part of
the title, even though it looks like it from a human point of view.
---Michael B.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:wtr-general-
[EMAIL PROTECTED] On Behalf Of Bret Pettichord
Sent: March 21, 2006 12:16 AM
To: [email protected]
Subject: Re: [Wtr-general] How can my script wait until a new window
hasfinished loading before using IE.attach?
The code base in development allows you to configure this.
IE.attach_timeout = 10
This is number of seconds to wait for the window specified in attach
statements to appear/load. This should be exactly what you are asking
for.
Paul, Mark, Anyone: Lemme know happens if you try this out. Does it
solve your problem?
(There is a lot of great stuff in development, which is why i'm eager
to stabilize the code base and make a new release.)
Bret
On 3/20/06, Paul Carvalho <[EMAIL PROTECTED]> wrote:
> Hello again,
>
> I am having a bit of difficulty getting my script to wait for a window to
> finish loading before attaching to it. Here's the original code:
> ----
> $ie.link(:text, 'View Report').click
>
> ie2 = IE.attach(:title, /View Report/)
>
> # stuff happens
>
> ie2.close
> ----
>
> If I run it as above, I get the following error:
> "Watir::Exception::NoMatchingWindowFoundException: Unable
> to locate a window with title of (?-mix:View Report)"
>
> The problem seems to be that the Title bar initially has a URL displayed
in
> it and then, after a while (random number of seconds), it updates to the
> correct <TITLE>. So the command will *eventually* work, but it will fail
if
> it checks the window too soon.
>
> I tried inserting a 'sleep' command between the first two lines above,
but I
> can't account for how long it will take the window to finish loading.
>
> I searched the message archives but I couldn't find anything that helps me
> tell the script to wait as long as it needs before trying to attach to the
> new window.
>
> I tried making up combinations of functions to try and help me, but so far
> nothing has helped. For example, I tried working with commands like:
> > IE.attach(:title, /View Report/).exists? # but this doesn't work
as
> I'd like
>
> and the ie.status() method only applies when you can actually connect to
the
> window first, so it doesn't help me either.
>
> I thought about creating a series of nested begin-rescue-end blocks to
catch
> and work with the exceptions, but I still couldn't quite figure out how to
> get it to wait the random amount of time required before trying to attach
to
> the window.
>
> Has anyone else encountered a similar problem before? Do you have any
> suggestions that might help?
>
> Please let me know. Thanks.
> Paul.
>
>
> _______________________________________________
> 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
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general