Skip to content

Commit

Permalink
docs - new interactions pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jjpaulo2 committed Aug 1, 2024
1 parent ee7d4a9 commit 5198025
Show file tree
Hide file tree
Showing 14 changed files with 418 additions and 94 deletions.
8 changes: 5 additions & 3 deletions docs/elements/index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Elements

> 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](http://xpather.com/) to help you building your xpaths.
!!! info "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](http://xpather.com/) to help you building your xpaths.

## Get elements from the page

Expand Down
3 changes: 2 additions & 1 deletion docs/elements/lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ False
```
### Print the items of the list

> To use this method, you need to install the **\[debug\]** extras, as [shown here](../index.md#installation).
!!! 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_list.print()
Expand Down
3 changes: 2 additions & 1 deletion docs/elements/selects.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ False

### Print the options of the select

> To use this method, you need to install the **\[debug\]** extras, as [shown here](../index.md#installation).
!!! 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_select.print()
Expand Down
3 changes: 2 additions & 1 deletion docs/elements/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ False

### Print the table in console

> To use this method, you need to install the **\[debug\]** extras, as [shown here](../index.md#installation).
!!! 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_table.print()
Expand Down
75 changes: 75 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,78 @@ type(web)
```python title="Output"
fastrpa.app.Web
```

## The Web objects

Once you have a `Web` object, you are able to browse on the web. The `Web` class is a abstraction of main browser and user functions.

### Get the current URL from the browser

```python linenums="1"
web.url
```

```python title="Output"
'https://www.site.com/mypage'
```

### Get the domain from the current URL

```python linenums="1"
web.domain
```

```python title="Output"
'www.site.com'
```

### Get the title from the current page

```python linenums="1"
web.title
```

```python title="Output"
'My website'
```

### Navigate to an URL

```python linenums="1"
web.browse('https://www.site.com/another_page')
```

### Refresh the current page

```python linenums="1"
web.refresh()
```

### Check if an element is interactive on the screen

```python linenums="1"
web.is_interactive('//*[@id="myElement"]')
```

```python title="Output"
False
```

### Get the from text content from an element

```python linenums="1"
web.read('//*[@id="myElement"]')
```

```python title="Output"
'Any text'

```

## Next steps

- [Configure the selenium integration](./selenium.md)
- [Running interactions with the current page](./interactions/index.md)
- [Manipulating elements](./elements/index.md)
- [Get xpaths in a easier way](./low-level.md)
- [Use the selenium/requests API directly](./low-level.md)
34 changes: 29 additions & 5 deletions docs/interactions/console.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
To run javascript on the current page, you can use the following methods.

## Accessing the object

```python linenums="1"
app = FastRPA()
web = app.browse('https:...')
type(web.console)
```

```python title="Output"
fastrpa.core.console.Console
```

## Reference

# To just evaluate a simple expression
### Evaluate a simple expression

```python linenums="1"
web.console.evaluate('2 + 2')
```

```python title="Output"
4
```

### Run multi line scripts

# To run complex and multi line scripts, use this
web.console.run(['button = document.getElementById("myButton")', 'button.click()'])
```python linenums="1"
web.console.run([
'button = document.getElementById("myButton")',
'button.click()'
])
```

# To run a script file, use this
### Run a javascript file

```python linenums="1"
web.console.run_script('/path/to/script.js')
```
```
74 changes: 64 additions & 10 deletions docs/interactions/cookies.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,91 @@
An abstraction to manage cookies on the current domain.

## Accessing the object

```python linenums="1"
app = FastRPA()
web = app.browse('https:...')
type(web.cookies)
```

```python title="Output"
fastrpa.core.cookies.Cookies
```

## Reference

### Get the list of cookies on the current domain

# Get the list of cookies on the current domain
```python linenums="1"
web.cookies.list
```

```python title="Output"
[Cookie(...), Cookie(...)]
```

### Get the list of names from the cookies on the current domain

# Get the list of names from the cookies on the current domain
```python linenums="1"
web.cookies.list_names
```

```python title="Output"
['JSESSIONID', '_ga', ...]
```

### Check if a cookie exists on the current domain

# Check if a cookie exists on the current domain
```python linenums="1"
'my_cookie' in web.cookies
```

```python title="Output"
True
```

### Check if a cookie stores some value

# Check if a cookie stores some value
```python linenums="1"
web.cookies.check('my_cookie', 'value')
```

```python title="Output"
False
```

# Get a cookie on the current domain
### Get a cookie on the current domain

```python linenums="1"
web.cookies.get('my_cookie')
```

```python title="Output"
Cookie(name='...', value='...', domain='...', path='/', secure=True, http_only=True, same_site='Strict')
```

### Get a cookie that does not exist the current domain

# Try to get a cookie that does not exist the current domain
```python linenums="1"
web.cookies.get('my_cookie')
```

```python title="Output"
None
```

### Add a new cookie on the current domain

```python linenums="1"
web.cookies.add('my_cookie', 'value')
```

# Add a new cookie on the current domain
web.cookies.add('my_cookie', 'value', secure=False)
```python title="Output"
Cookie(name='my_cookie', value='value', domain='...', path='/', secure=False, http_only=True, same_site='Strict')
```

### Delete a cookie on the current domain

# Delete a cookie on the current domain
```python linenums="1"
web.cookies.delete('my_cookie')
```
```
31 changes: 1 addition & 30 deletions docs/interactions/index.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,4 @@
Once you have a `Web` object, you are able to browse on the web. The `Web` class is a abstraction of main browser and user functions.

```python linenums="1"
# The current URL from the browser
web.url
'https://www.site.com/mypage'

# The domain from the current URL
web.domain
'www.site.com'

# The title from the current page
web.title
'My website'

# Navigate to an URL
web.browse('https://www.site.com/another_page')

# Refresh the current page
web.refresh()

# Check if an element is interactive on the screen
web.is_interactive('//*[@id="myElement"]')
False

# Get the from text content from an element
web.read('//*[@id="myElement"]')
'Any text'

```
# Interactions

You can also, manage the following items:

Expand Down
37 changes: 29 additions & 8 deletions docs/interactions/keyboard.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
You can send keyboard events to the current page, by using the methods below.

## Accessing the object

```python linenums="1"
app = FastRPA()
web = app.browse('https:...')
type(web.keyboard)
```

# To send a simple key press event
web.keyboad.press('control')
web.keyboad.press('escape')
web.keyboad.press('enter')
```python title="Output"
fastrpa.core.keyboard.Keyboard
```

# To send a keyboard shortcut event
web.keyboad.shortcut('control', 'a')
web.keyboad.shortcut('control', 'shift', 'c')
## Reference

!!! info
All keyboard methods are case insensitive.

### Get the available command keys

# To see the available command keyboard keys
```python linenums="1"
web.keyboad.keys
['ADD',
'ALT',
Expand All @@ -24,4 +30,19 @@ web.keyboad.keys
'BACKSPACE',
'BACK_SPACE',
...
```

### Simple key press event

```python linenums="1"
web.keyboad.press('control')
web.keyboad.press('escape')
web.keyboad.press('enter')
```

### Keyboard shortcut event

```python linenums="1"
web.keyboad.shortcut('control', 'a')
web.keyboad.shortcut('control', 'shift', 'c')
```
Loading

0 comments on commit 5198025

Please sign in to comment.