Elements
FastRPA is xpath-oriented!
FastRPA is totally based on xpath locations. It means that does not exists any way, but xpath, to access elements from the web pages. This is a important concept that guarants the consistence on framework's code base.
If you want to obtain elements using another identifier, just write an xpath that wraps that identifier. For example, if you want to get a div with an id my_div
, just use the xpath //*[@id="my_div"]
. You can use a site like xpather.com to help you building your xpaths.
Get elements from the page
To start our interactions with page elements, we just need to obtain these with the methods shown below.
Get just one element or the first found
The wait strategy
By default, FastRPA always waits until the element is interactable. The default timeout is 15 seconds, and it is configurable by the FastRPA constructor. In case of timeout, you will receive a ElementTimeoutException
.
Traceback (most recent call last):
...
ElementTimeoutException: Element [//*[@id="my_div"]] not found after 60 seconds!
Disabling the waiting
If you don't want to wait, just send a wait=False
parameter to the element method.
If you try to get an element that is not in the page, you will get an ElementNotFoundException
.
Traceback (most recent call last):
...
ElementNotFoundException: No one element [//*[@id="my_div"]] was found!
Get all elements found
In the case of trying to get many elements, the framework will now run a wait strategy.
Traceback (most recent call last):
...
ElementNotFoundException: No one element [//*[@id="my_div"]] was found!
Elements abstractions
There is some abstractions that implements actions and rules for specific elements. They is listed below.
Class | HTML5 tags |
---|---|
Element |
any element |
InputElement |
input , textarea |
FileInputElement |
input type="file" |
RadioInputElement |
input type="radio" |
CheckboxElement |
input type="checkbox" |
SelectElement |
select |
ListElement |
ol , ul |
ButtonElement |
button , a |
FormElement |
form |
TableElement |
table |
ImageElement |
img |
Element reference
To interact with generical Element
instances, you can use the properties and methods below.