-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs - adding checkbox and radio elements
- Loading branch information
Showing
3 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
description: Interactions with input tag with attribute [@type="checkbox"]. | ||
--- | ||
|
||
Interactions with `input` with attribute `type="checkbox"`. | ||
|
||
## Reading the element | ||
|
||
### Getting the right element class for the xpath | ||
|
||
```python linenums="1" | ||
my_check = web.checkbox('//*[id="myCheckbox"]') | ||
type(my_check) | ||
``` | ||
|
||
```python title="Output" | ||
fastrpa.core.elements.CheckboxElement | ||
``` | ||
|
||
### Try to get a `CheckboxElement` | ||
|
||
```python linenums="1" | ||
my_check = web.checkbox('//*[id="myCheckbox"]') | ||
type(my_check) | ||
``` | ||
|
||
```python title="Output" | ||
fastrpa.core.elements.CheckboxElement | ||
``` | ||
|
||
## Reference | ||
|
||
### Get if is checked | ||
|
||
```python linenums="1" | ||
my_check.is_checked | ||
``` | ||
|
||
```python title="Output" | ||
False | ||
``` | ||
|
||
### Mark as checked | ||
|
||
Only marks the checkbox as checked/active. | ||
|
||
```python linenums="1" | ||
my_radio.check() | ||
``` | ||
|
||
### Mark as unchecked | ||
|
||
Only marks the checkbox as unchecked/inactive. | ||
|
||
```python linenums="1" | ||
my_radio.uncheck() | ||
``` | ||
|
||
### Switch the value | ||
|
||
Just switch the checkbox value. If it's checked, it will be unchecked, and vice versa. | ||
|
||
```python linenums="1" | ||
my_radio.switch() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
--- | ||
description: Interactions with input tag with attribute [@type="radio"]. | ||
--- | ||
|
||
Interactions with `input` with attribute `type="radio"`. | ||
|
||
## Reading the element | ||
|
||
### Getting the right element class for the xpath | ||
|
||
```python linenums="1" | ||
my_radio = web.radio_input('//*[id="myRadioInput"]') | ||
type(my_radio) | ||
``` | ||
|
||
```python title="Output" | ||
fastrpa.core.elements.RadioInputElement | ||
``` | ||
|
||
### Try to get a `RadioInputElement` | ||
|
||
```python linenums="1" | ||
my_radio = web.file_input('//*[id="myRadioInput"]') | ||
type(my_radio) | ||
``` | ||
|
||
```python title="Output" | ||
fastrpa.core.elements.RadioInputElement | ||
``` | ||
|
||
## Reference | ||
|
||
### Get all radio options | ||
|
||
Given one radio element, you can query by another options for that same input `@name` attribute. This method will returns a dict with radio values and it's respective label text associated. | ||
|
||
```python linenums="1" | ||
my_radio.options | ||
``` | ||
|
||
```python title="Output" | ||
{'option1': 'Default radio', | ||
'option2': 'Second default radio'} | ||
``` | ||
|
||
### Get all radio options values | ||
|
||
```python linenums="1" | ||
my_radio.options_values | ||
``` | ||
|
||
```python title="Output" | ||
['option1', 'option2'] | ||
``` | ||
|
||
### Get all radio options labels | ||
|
||
This method will return all texts from labels pointing to radio elements with same `@name` of the source radio element. | ||
|
||
```python linenums="1" | ||
my_radio.options_values | ||
``` | ||
|
||
```python title="Output" | ||
['Default radio', 'Second default radio'] | ||
``` | ||
|
||
### Select a radio option by label | ||
|
||
Following the same rule, you can select another radio from the form with the same `@name` of the source radio element. | ||
|
||
```python linenums="1" | ||
my_radio.select('Second default radio') | ||
``` | ||
|
||
### Select a radio option by value | ||
|
||
```python linenums="1" | ||
my_radio.select(value='option1') | ||
``` | ||
|
||
### To just active the source radio element | ||
|
||
```python linenums="1" | ||
my_radio.click() | ||
``` | ||
|
||
### Check if radios have some option | ||
|
||
To check by both label and value. | ||
|
||
```python linenums="1" | ||
'Other option' in my_radio | ||
``` | ||
|
||
```python title="Output" | ||
False | ||
``` | ||
|
||
### Check if radios have some option label | ||
|
||
```python linenums="1" | ||
my_radio.has_option('Other option') | ||
``` | ||
|
||
```python title="Output" | ||
False | ||
``` | ||
|
||
### Check if radios have some option value | ||
|
||
```python linenums="1" | ||
my_radio.has_option(value='3') | ||
``` | ||
|
||
```python title="Output" | ||
False | ||
``` | ||
|
||
### Print the options of the radio | ||
|
||
!!! warning "Extra needed!" | ||
To use this method, you need to install the **debug** extras, as [shown here](../index.md#installation), with the command `pip install "fastrpa[debug]"`. | ||
|
||
```python linenums="1" | ||
my_radio.print() | ||
``` | ||
|
||
```python title="Output" | ||
[@id="myRadioInput"] | ||
├── [1] Option 1 | ||
├── [2] Option 2 | ||
├── [3] Option 3 | ||
└── [4] Option 4 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters