SNIPPET: SAFE NAVIGATE

When using UBot navigate command you usually want to make sure that the page you are trying to load really gets loaded, and beside that when using proxies you may also want to re-try loading the page, in case proxy was down when UBot tried to load the page or if the proxy may not work at all. So to make your software more robust you should use some checks after navigate commands, to make sure that the page you are expecting to load has actually loaded and if not, a command that will try to load it again.

The code bellow navigates to a page that you provide as input parameter “#DEF Url“, waits for it to load and check if the right page was loaded and if so it returns value “true” (proxy code should be added by the final user – before navigate command or even outside the function). If from any reason page failed to load, the code will re-try to load; how many times it’s defined by global variable “#PAGE Load Retires” set inside the defined function. If we even fail in the last try the code will return “false”. For convenience you can control the wait time via global variable “#PAGE Load Timeout“.

Input Parameters

  • #DEF Url – URL we want to navigate to
  • #DEF Footprint Success – Footprint that designates that we are on the right page
  • #DEF Footprint Wait (OPTIONAL) – Footprint that will be used for “wait for element” command (if left empty, #DEF Footprint Success value will be used)

SNIPPET & TEST CODE

 

If you like this snippet or have any questions or suggestions, please feel free to leave a comment or subscribe to the RSS feed to have future snippets delivered to your feed reader.

Leave a Reply

Your email address will not be published. Required fields are marked *

*