Skip to content

Commit

Permalink
docs - adding checkbox and radio elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jjpaulo2 committed Aug 3, 2024
1 parent 03069cf commit 5c11582
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 0 deletions.
65 changes: 65 additions & 0 deletions docs/elements/checkboxes.md
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()
```
135 changes: 135 additions & 0 deletions docs/elements/radio-inputs.md
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
```
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ nav:
- Introduction: elements/index.md
- Inputs: elements/inputs.md
- File inputs: elements/file-inputs.md
- Radio inputs: elements/radio-inputs.md
- Checkboxes: elements/checkboxes.md
- Selects: elements/selects.md
- Lists: elements/lists.md
- Buttons: elements/buttons.md
Expand Down

0 comments on commit 5c11582

Please sign in to comment.