softwait is the Magic Duct Tape of webDOM
Written by: webDOMinator 3 years and 4 months ago
It's not only Duct Tape, it's Magic! Here's an example using the new dom.stateQuick Reference for "dom.state"
Click on command to see examples & comments
Top Level Dom Values
Description: Returns the numeric state of the browser. 4 is page loaded. 3 is when the page is loading and hasn't finished yet. variable that will use a softwait condition to ACT like a pagewait.
Code
navigateQuick Reference for "navigate"
Click on command to see examples & comments
Browser Level Commands
Usage: navigate:url
Description: Makes the browser navigate to the URL specified.:webdombot.com/updates.php
clickQuick Reference for "click"
Click on command to see examples & comments
DOM Level Commands
Usage: click:element
Description: Clicks a DOM element specified by element.:dom.a.Testimonials
wait:1
softwaitQuick Reference for "softwait"
Click on command to see examples & comments
Script Level Commands
Usage: softwait:condition
Description: Waits using a timer, and breaks out of the script allowing other events to happen. Once the condition is met, it returns to the waiting script and continues. This is good for use with pages which load elements using javascript which you want to load before interacting with them. condition can be a number of seconds to wait or a Minion condition.:
dom.stateQuick Reference for "dom.state"
Click on command to see examples & comments
Top Level Dom Values
Description: Returns the numeric state of the browser. 4 is page loaded. 3 is when the page is loading and hasn't finished yet.==4
echoQuick Reference for "echo"
Click on command to see examples & comments
Script Level Commands
Usage: echo:statement
Description: Echoes a statement to the status output. The statement can be a literal string, or a concatenated string.:this is like a pagewait, but better
If you run that code, you will see it perform exactly like a page wait. But instead of using the event system of the webBrowser control, it uses webDOM's own built in event system... thus, let's say that there was no testimonials link, and you wanted your script to continue anyway, the above script would do this. Notice the wait:1 before the softwait command, this is to give the web browser a little time to react to the click and start loading the next page before it tries to start checking for the page to be finished loading.
Sometimes you need to make webDOM softwait just to break your script out of the main order of operations. The order of operations, or what happens when a web page loads in webDOM is that, the browser has to send a signal to it's parent (in this case webDOM)... when webDOM picks up this signal, it performs whatever script you're trying to run, then it gives control back to the web browser. The web browser then continues with whatever javascript or vbscript it has to run on the page.
This means that webDOM's scripts happen exactly after the page load... or the moment that the page is loaded, and that your minion sripts have priority over javascript in the order of operations.
Here's the problem...
Sometimes you need those extra javascripts to run in order to interact with the completed page properly, like in the case with sites that are heavy web2.0 (Ajax) sites. Sometimes the javascript that runs loads the elements dynamically into the page that you need to interact with. Before softwait, there was not a way to get at them; no matter how much you used the "wait" command, the webBrowser would just wait until your Minion script was done running to run it's javascripts