Establish
This command is a Flow Command. The establish command tests to see if the scripting environment (the webpage, a variable, a list, etc) is as it should be for the bot to run successfully.
Establish Message: The message that will be logged indicating that the state of the bot's environment is stable.
Example
clear all data ui log view("Log") purpose("Create an account") navigate("http://www.ubotstudio.com/playground/simple-form","Wait") establish("I am on the account creation page.",$search page("Sample Account Creation Form:"),"No") { alert("We were unable to find the correct page") pause script } type text(<username field>,"Seth","Standard") type text(<password field>,"password","Standard") type text(<first name field>,"Seth","Standard") type text(<last name field>,"Turin","Standard") type text(<about me textarea>,"I heart UBot Studio.","Standard") click(<value="Submit">,"Left Click","No") wait(3) establish("The account was properly created",$search page("Account Created"),"No") { alert("The account was not created properly") pause script }
Running the script logs two establish messages:
1. I am on the account creation page: Indicating that the bot is free to continue on with account creation.
2. The account was properly created: Indicating that the account was created without issue as a result of the state of the webpage.
When the log files are viewed, the following logs are found for the entirety of the script:
2015-03-15 21:00:36 [PURPOSE] Create an account 2015-03-15 21:00:37 [ESTABLISH] "I am on the account creation page." 2015-03-15 21:00:37 Already Established 2015-03-15 21:00:42 [ESTABLISH] "The account was properly created" 2015-03-15 21:00:42 Already Established
Successful establish messages will display in green.
The logs indicate that the bot was able to visit the account creation page and create an account.
Now what if the bot is NOT on the correct page? In the example script below, the bot navigates to a different website without creating the account.
clear all data ui log view("Log") purpose("Create an account") navigate("http://www.ubotstudio.com/playground/simple-form","Wait") establish("I am on the account creation page.",$search page("Sample Account Creation Form:"),"No") { alert("We were unable to find the correct page") pause script }
Because the bot's environment is not at the state we predicted, the alert message appears stating that there was trouble finding the correct webpage.
The logs display the following messages:
2015-03-15 21:57:43 [PURPOSE] Create an account 2015-03-15 21:57:45 [ESTABLISH] "I am on the account creation page." 2015-03-15 21:58:20 Failed to establish <pre> [[File:establish0.jpg]] Failed establish messages will be displayed in red.