Konw whether the browser has finished loading or not?

Hello people, I’m asking how to know whether the browser has finished loading or not ??

2 Likes

Hi @Hazem,

You can use “Find Element” or “Element Exists” or “On Element Appear” activity with appropriate value in TimeoutMS property.

Regards
Vitan

This will happen by default with web UI Automation activities that have WAIT_FOR_READY = Complete. They will execute only after the web page has been fully loaded.

4 Likes

@badita @Vitan Thanks for your helpful reply,but actually when the browser has been fully loaded,there could be 2 things,either the browser navigated to the URL correctly (meaning internet is working) or the browser failed to connect (meaning no internet connection)…so I want just to know if the browser is fully loaded or not <<then use element exist with very small timeout to determine whether the browser navigated correctly to the site or not ??

Doesn’t ElementExists with WAIT_FOR_READY=Complete and a longer timeout (default is 3 secs) work?

@badita so if I used the element exists activity with WAIT_FOR_READY=Complete .It will wait till the page is fully loaded whatever the timeout was ?

Yes. Not sure what happens if redirects are involved but test it.

@badita It didn’t work,the activity didn’t wait till the page is fully loaded and processed to the next step after the timeout if finished

Have you increased the TimeoutMS from 3000ms?

ElementExists returns a true/false - if it doesn’t find the element in the timeout, it will return false. You need to check it’s result after, f.e. in an If.

If you want to wait indefinitely, just set a really high timeout or set a `While(Not myElementExists) { ElementExists(…) }. Or a retry scope might be good for you as well.

@andrzej.kniola Actually if did increase the timeout to the average time the page takes to load then I may increased it to over a Minuit .
while the the browser actually has failed to navigate to the page !! so it will search for an element that will never be existed

Increase it to over a minute. If the element is found sooner it will continue without waiting.

1 Like

Yes,I know,but If I did that the activity will take the whole period to decide that the element isn’t existed and that’s would be much time to wait !! . I believe your solution is good but it’ll takes too much time !
and thanks in advance @badita

It won’t. [quote=“badita, post:12, topic:5820”]
If the element is found sooner it will continue without waiting.
[/quote]

But try it.

1 Like

I ran in to a similar problem, and the only workaround I found was to add a “Get attribute” activity after the “navigate to” one.

The “Get attribute” activity has “” as a selector, and “readystate” as the attribute name. This will cause the process to wait for the page to load.

3 Likes

@bogdanripa

Could you put your selector from the previous post into a code snippet? HTML tags get sanitized on the forum and I would really like to see that selector :slight_smile:

This is very helpful! Thanks a lot!