in reply to Re^2: How do I add a timeout to Win32::IEAutomation click method
in thread How do I add a timeout to Win32::IEAutomation click method

I don't see anything in the doc about page state check.

What doc?

You are aware that Win32::IEAutomation is only half the docs (more like 5%)?

Win32::IEAutomation uses Win32::OLE to automate InternetExplorer.Application, msdn is where 95% of the docs live, and a whole bunch of that 95% is DOM documentation

Ok, back to checking if page is loaded, we start where we left off with nowait, so if you go to Win32::IEAutomation and Ctrl+Find in page for "wait" you'll find WaitforDone()

If you UTSL and look inside of WaitforDone you will see

sub WaitforDone{ my $self = shift; my $agent = $self->{agent}; while ($agent->Busy || $agent->document->readystate ne "complete") +{ sleep 1; } }

So you can monkeypatch yourself a $ieauto->WaitforDoneTimeout( 6 );

sub Win32::IEAutomation::WaitforDoneTimeout { my( $self, $timeout ) = @_; $timeout ||= 0; my $starttime = time; my $agent = $self->{agent}; while( 1 ){ my $loaded = !!( $agent->Busy || $agent->document->readystate +ne "complete" ); return "loaded" if $loaded; sleep 1; if( (time - $starttime) > $timeout ){ return "timedout"; } } return "nuclear explosion"; }

Also if you started from Click by looking inside https://metacpan.org/source/PRASHANT/Win32-IEAutomation-0.5/lib/Win32/IEAutomation/Element.pm#PWin32::IEAutomation::Element

sub Click{ my ($self, $nowait) = @_; $self->{element}->click; $self->{parent}->WaitforDone unless $nowait; }

you'd find WaitforDone , so the circle is complete ... that is ieautomation ;)

more generic win32 tips

If you want to automate anything on win32 you have to absorb the following knowledge . It mostly consists of learing the ole/excel/powerpoint... object model, and using Win32::OLE to call it or sending messages using guitest. OLE is essentially a fancy/standardised way of sending messages. Its very much like web-scraping, you have to know HTTP/HTML DOM .... the rest is just legwork

Replies are listed 'Best First'.
Re^4: How do I add a timeout to Win32::IEAutomation click method
by Redbeard36 (Initiate) on Apr 08, 2014 at 13:42 UTC

    This seemed like a lot, until I worked through making it work. I'm glad for the help, as it would've taken me forever to figure this out. I knew that IEAutomation used OLE as its base, but didn't know how to adjust it, and also didn't know about monkeypatching. Surprisingly, I had read most of the items in your Win32 info during other automation. Like I said before I am very new to this.

    Sorry for the n00b questions, and thanks again for all the help.