Before we create an RPA automation process by ourselves, let's get familiar with some terms.
Data is stored in an object in the form of {key: value}. As shown in the diagram below, we can use an object to represent a person's information. In this object {...}, "Name," "Age," and "Gender" are keys, while "Jack," "25 years old," and "Male" are values.
As shown below, there are 2 objects, each representing information about a different person.
An array is an ordered collection. Let's start with a simple array. As shown in the image, the array contains 4 elements. The array index starts from 0, a[0] represents the first element of the array, a[1] represents the second element of the array, a[2] represents the third element of the array, and so on.
The elements in an array can also be objects. As shown in the image, there is an array containing 3 objects.
As shown in the image, the values of a[0], a[1], and a[2] are:
Now, you should have a clear understanding of the concepts of arrays and objects. If you are still not familiar, it is recommended to Google the relevant knowledge for further learning. Search keywords such as: JavaScript arrays, objects.
What are CSS selectors? CSS selectors are used to "find" (or select) the elements you want to style with CSS.
Let's see an example!
Suppose there are 10 posts on a page, and only the 5th post is the one you want to like using RPA. To achieve this, you need to use a selector to locate the "Like" button on the 5th post and then click on it. Without a selector, RPA has no way of knowing which element to find.
As shown below, enter the selector #nav-search-submit-button
, then RPA will click on elements containing <xxxx id=nav-search-submit-button>
within the page.
The following code is an example to explain how to use the three selectors: learning document
<div class="one_class">one</div>
<p class="two_class">two</p>
<span id="three_class">three</span>
Selector Type | Description |
---|---|
Selector | Refers to a CSS selector, a method for selecting HTML elements using CSS syntax. For example, using the CSS selector .one-class can select all elements with the class name one-class, allowing you to retrieve elements like one in the above code. |
XPath | XPath is a language used to find nodes in XML and HTML documents. It uses path expressions to select elements, which can be very specific, including the element's attributes, text content, position, etc. For example, //p[@class='two-class'] will select all p elements with the class name two-class. |
Text | Directly fill in the text of the element you want to select. For example, if you enter "three", you can directly retrieve that element. |
Variables (officially known as custom properties) are placeholders that store reusable values in CSS. You can save a value in a variable, and you can call it later via the variable.
Actions such as [Get Data-URL], [Get Data-Element] and [Data Processing-For Loop Elements] can help store elements that can be reused later in variables.
There are many cases where you want certain code to run only when a specific condition is met, and a different set of code to run when the condition is not satisfied.
For example, we enter the password in the input box on the account login page, or refresh the page if there is no input box. That's where [Statement if] comes in handy.
If this expression evaluates to True, then run once the code that follows the expression. If it isn't True, then don't run the block of code that follows or run the code in "Else".
Loops can execute a block of code over and over again.
For example, loops are handy, if you want to like many posts, save all reviews under an item to a file, or click on multiple pictures.
There are 2 kinds of For Loops in AdsPower: [For Loop Elements] and [For Loop Times]. Please refer to the chapter "Process Management" for more details.