Commands:Choose by attribute

Choose by attribute is probably one of the most common commands that you will use in UBot, because it is part of the foundation of how UBot communicates with webpages. Before you can manipulate a part of a webpage, you must first choose it. You can choose an element of a page by any of its attributes. Selecting a value in the parameters window will display its current value under the search parameter.

This is particularly useful if you need to choose something like a select box, or a checkbox. You can put it in the state that is most useful, and then when choosing it, the value will be ready to go. With checkboxes, use the "checked" attribute.

You can make the search value more flexible by using wildcards and regular expressions. Wildcard cards are * and ?. * will allow for any number of any character, while ? will allow for just one random character. Regular expressions are much more powerful search tools than wildcards, but are outside the scope of this explaination. Many tutorials for regular expressions can be found online. Most of the time, wildcards are enough. Because choosing elements can be simple sometimes and surprisingly tricky others, UBot has multiple methods for choosing elements by the attribute.



Let’s say you wish to select an image on a page—perhaps a captcha that you’d like to solve. You have several options. If you are on Facebook’s signup page and you right click their captcha image, and use the choose by attribute command, you will see the following:



The best attribute for selecting a captcha is by “src”, but first you must limit the source because the URL is usually randomized. Changing the search method to “wildcards” and adding an asterisk (*) in place of the random portions of the search string, we can easily select the captcha every time it loads:



UBot recognizes all of the different available ways to select an element on the page, including by the element’s name, id, type, size, innerhtml, outerhtml, height, width, and more. There should be almost no elements that UBot cannot select. Because some sites try to make portions of the page difficult to select, you will quickly find that the best attribute for selecting an element can vary from page to page.

Using the choose by attribute command on a text box will bring up a window like the following:



In this instance, you could use the “name” of the box as well as the “id”. If one attribute isn’t working when you try to select it, there may be multiple elements on the page with the same attribute. With UBot’s many options, you will be able to find an attribute that works 99% of the time.