The UBot Studio SCRIPT REFERENCE
The Chosen Commands
CHOSEN COMMANDS CLICK CHOSEN CHANGE CHOSEN ATTRIBUTE SELECT RANDOM CHILD CHOSEN SEND KEYS FILE CHOSEN SEND KEYS FIELD CHOSEN CHANGE FILE FIELD CHOSEN FOCUS CHOSEN SCRAPE CHOSEN TABLE SAVE CHOSEN IMAGE
CHOSEN COMMANDS: CLICK CHOSEN: This command will click a link or a button. You can also use it to check or uncheck a checkbox. There are no parameters required for this command, it is simply placed after the node that identifies the element (i.e. choose by attribute, choose by position, etc).
In this example you can see the element (web button) was chosen by attribute (1) and the click chosen command was placed directly after it (2). Running this script will cause the button to be pressed and will navigate to the sales page.
CHANGE CHOSEN ATTRIBUTE: This command, after choosing an element, lets you change a value within that element. This is useful for, among other things, filling in form fields, setting checkboxes to a given value, setting drop down fields, and selecting radio buttons. When brought into the scripting area you will need to provide two (2) parameters: 1. 2.
Attribute to change Value
In this example we will use it to fill a form field with a specified value. Like any other node, you can pull your content from a variety of sources (i.e. lists, variables, files, etc).
We will be using the ubotstudio.com playground (simple form) fpr this example:
Since all the form fields use the same process for filling them we will only be filling one field: Step 1) Right click inside the username field and select “choose by attribute”. By default it will have the attribute “Name” chosen, which is fine for this example. In this case you can see in the image below that the element has a unique name. We will leave it as is and keep the search method on exact match.
Click ok. Step 2) Right click inside the username field again and select “change chosen attribute.
Although it defaults to “name” you want to change it to “value” and enter whatever value you like. Click “OK” and that's it. When you run the script it will fill that field with your specified username.
SELECT RANDOM CHILD CHOSEN: This command is very useful for dealing with drop down lists. It allows you to have the script randomly choose a value from the drop down list.
The first step is to right click the drop down menu and choose it by attribute:
Again, the name attribute is fine in this example. Click ok.
Now right click the drop down menu again and click on select random child chosen. The entire code looks like this:
It will now choose a random value from the drop down list every time you run the script.
SEND KEYS FILE CHOSEN: This command is used specifically for filling text into file input fields, as a means of getting around the lack of direct access to them. This command will not steal focus, and runs entirely in the background. To simulate typing on elements other than file fields, use send keys chosen field. This command no longer works if you have internet explorer 8 installed.
In the above image the form field is chosen by attribute (1), and then filled with the specified path (2). In some cases when you are unable to use the browse button, this technique may work for you instead.
SEND KEYS FIELD CHOSEN: This command will simulate keystrokes to input fields other than file fields. This is useful in cases where the field reacts to keystrokes with javascript, and change chosen attribute does not trigger the javascript associated with the element.
Above is an example of a form where the button is not activated unless triggered by keystrokes, etc. For the field containing the first name we would simply choose the field by attribute and then use the send keys field chosen command to simulate the keystrokes:
When changing chosen attribute does not trigger the activation, this is the next logical step to take.
CHANGE FILE FIELD CHOSEN: This command sets the file in a file field. In this example you will see a file upload field that has a browse button. This command allows you to enter the file without interacting with the browse function (It places the path to the file directly in the file field):
The first step is to choose the file field by attribute:
The final step is to choose the “change file field chosen� command and enter the path to your file:
When the script is run, this is the result:
FOCUS CHOSEN: This command brings the chosen element into focus. This can be very useful with the input commands. In this example we will click a button that is not responding to the “click chosen� command. The first step is to choose the button by attribute. Here is the button we are dealing with:
Choose by attribute:
Add the focus chosen command:
Now when this script is run you will see the button has been given focus (The small dotted line inside the button):
Now you can use a send keys command under input commands to hit “Enter� to press the button:
Once the entire script is run you can see the button has been pressed:
When the button is pressed it changes the background color to yellow.
SCRAPE CHOSEN TABLE: This command creates a table based on a chosen table. For the purpose of this example we will use the table located at http://www.w3schools.com/html/html_tables.asp :
If you recall from previous discussions the structure of a table is as follows:
...where the first column and the first row are both 0's and not 1's. So Bob would be located in column 0, row 0.
That will be essential to understand later when you are trying to grab data from your table. To begin this example, we can clearly see that the fruit names and percentages are part of a table (you can actually see the borders of the table). Therefore the first step is to pick anything inside the table and choose it by attribute. For this example we will choose apples:
The reason you can choose anything in the table is because you will be using the choose ancestor command to grab the table. You will find this command in the right click menu when you right click on the item you just chose by attribute (apples):
You will then be asked for the html tag you would like to use. In this case it is “table” (without the quotes):
The final step is to select the “scrape chosen table command and bring it into the scripting area (either by dragging it or double clicking it): You will give the table a name (and don't forget to add a “clear table” command at the top of the script). Just so you can see the structure of the scraped table, we will save the table to a .csv file and then open it up. We do this by using the save to file command (under variable commands) and giving it a name and a location:
Once the script is run we can locate the csv file in our documents
folder and open it up:
As you can see the table was scraped intact. Apples is located in column 0, row 0 and it's corresponding percentage is located in column 1, row 0. You now have the option to use the “create table from file� command to create this table at a future time.
SAVE CHOSEN IMAGE: This command allows you to save the image of an element. Using the website from the example above we are simply going to save the site's logo as an image on our hard drive:
This requires only two nodes:
As a result of running that script, the image is saved to your desktop:
That's it. Simply choose an image by attribute and use the save chosen image command. Give it a name and a location (path to the image file).