sub _wait_while_busy { my $self = shift; my $agent = $self->{agent}; # The documentation isn't clear on this. # The DocumentComplete event roughly says: # the event gets fired (for each frame) after ReadyState == 4 # we might need to check if the first one has frames # and do some more checking. my $sleep = 4; # 0.4; # while ( $agent->{Busy} == 1 ) { $sleep and sleep( $sleep ) } # return unless $agent->{ReadyState}; while ( $agent->{ReadyState} <= 2 ) { $sleep and sleep( $sleep ); } $self->{ $_ } = undef for qw( forms cur_form links images ); return $self->success; }