Jump to content
UBot Underground

click() followed by wait for browser() is not waiting for the page to load?


Recommended Posts

Hello everyone! My name is Brandon and this is my first post. I'm new to uBot and the forum, but not to programming bots -- I have been writing them in VB and C# .Net using the Web Browser control and directly accessing the DOM as well as "raw" using C, Python and PHP (via sockets directly) on-and-off for a decade now. I thought I'd give uBot Studio a try in order to speed up the development of automation bots I do write as technologies like AJAX and other advanced Javascript, Flash, Java etc. have made my techniques more difficult and time consuming, so please bare with me.

 

I have run into an issue with using click() followed by a wait for browser() command. Take for example the following code from my first bot:

 

    click(<create account button>, "Left Click", "No")
    wait for browser event("Everything Loaded", 60)
    if($search page("Welcome to")) {
      then {
        ....
        alert("Successfully created account!")
      }
      else {
        alert("Error creating account!")
      }
    }

 

wait for browser () seems to be returning to script execution quite quickly and prematurely, and the $search page function is not running with the proper page to search. I believe it's attempting to search the sign-up page. On what events does wait for browser with event "Everything Loaded" trigger? Would it trigger on a 30x HTTP code redirect or anything? I don't believe there's an intermediate page, but if there were, how would I go about determining which page I'm looking at prior to running the $search page() function? The next page loaded after click(), as far as I can tell, is a page informing the user to success or failure of account creation.

 

Can anyone shed some light on this?


Thanks in advance! This forum has been quite helpful already, even though I've just been lurking!

 

Brandon 

Edited by brandonpoc
Link to post
Share on other sites

simple - use "wait for element" command - make it wait for element on your target page

I certainly did this, and indeed it's working. However, there will be instances where an error occurs (such as the incorrect CAPTCHA is entered) so I am thinking of having a loop that wait()s for 1 second and checks whether an error message or a success message is present on the page, with a counter counting to 30. Upon hitting 30 it will exit from the loop, in effect creating a time-out of 30 seconds (give or take, due to process scheduling) waiting for either error or success and setting a value. If error nor success were achieved, it will restart. I think this will be a decent workaround.

 

Thanks for the help,

 

Brandon

Link to post
Share on other sites

Nowadays a page load doesn't mean much since so many sites use Ajax which is independent of page loads. So although the actual browser load has stopped other elements may still be loading through Ajax.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...