From 5c115825bbf106149ff9b28a291ff892c2ec5af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Carvalho?= Date: Fri, 2 Aug 2024 23:55:01 -0300 Subject: [PATCH] docs - adding checkbox and radio elements --- docs/elements/checkboxes.md | 65 ++++++++++++++++ docs/elements/radio-inputs.md | 135 ++++++++++++++++++++++++++++++++++ mkdocs.yml | 2 + 3 files changed, 202 insertions(+) create mode 100644 docs/elements/checkboxes.md create mode 100644 docs/elements/radio-inputs.md diff --git a/docs/elements/checkboxes.md b/docs/elements/checkboxes.md new file mode 100644 index 0000000..82a1f49 --- /dev/null +++ b/docs/elements/checkboxes.md @@ -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() +``` diff --git a/docs/elements/radio-inputs.md b/docs/elements/radio-inputs.md new file mode 100644 index 0000000..7e61589 --- /dev/null +++ b/docs/elements/radio-inputs.md @@ -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 +``` \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 02eef81..c8cbe74 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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