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


In reply to Re^3: How do I add a timeout to Win32::IEAutomation click method by Anonymous Monk
in thread How do I add a timeout to Win32::IEAutomation click method by Redbeard36

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.