Skip to content

Commit

Permalink
chore - fastrpa class tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jjpaulo2 committed Aug 2, 2024
1 parent 7fc5780 commit 64ebeaa
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/elements/buttons.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Interactions with <button> and <a> tag.
description: Interactions with button and a tags.
---

Interactions with `button` and `a` tags.
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/file-inputs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Interactions with <input> tag with attribute [@type="file"].
description: Interactions with input tag with attribute [@type="file"].
---

Interactions with `input` with attribute `type="file"`.
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/forms.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Interactions with <form> tag.
description: Interactions with form tag.
---

Interactions with `form` tag.
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/images.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Interactions with <img> tag.
description: Interactions with img tag.
---

Interactions with `img` tag.
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/inputs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Interactions with <input> and <textarea> tags.
description: Interactions with input and textarea tags.
---

Interactions with `input` and `textarea` tags.
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/lists.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Interactions with <ol> and <ul> tag.
description: Interactions with ol and ul tag.
---

Interactions with `ol` and `ul` tags.
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/selects.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Interactions with <select> tag.
description: Interactions with select tag.
---

Interactions with `select` tag.
Expand Down
2 changes: 1 addition & 1 deletion docs/elements/tables.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Interactions with <table> tag.
description: Interactions with table tag.
---

Interactions with `table` tag.
Expand Down
3 changes: 3 additions & 0 deletions docs/interactions/keyboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ fastrpa.core.keyboard.Keyboard

```python linenums="1"
web.keyboad.keys
```

```python title="Output"
['ADD',
'ALT',
'ARROW_DOWN',
Expand Down
66 changes: 63 additions & 3 deletions tests/test_app_fastrpa.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from unittest.mock import patch, MagicMock
from selenium.webdriver import ChromeOptions
from selenium.webdriver import ChromeOptions, FirefoxOptions
from fastrpa import FastRPA
from fastrpa.app import Web


@patch('fastrpa.app.Remote')
def test_create_generical_instance_use_remote_webdriver(remote_mock: MagicMock):
def test_generical_instance_use_remote_webdriver(remote_mock: MagicMock):
FastRPA().web()
assert remote_mock.call_count == 1

Expand All @@ -13,4 +14,63 @@ def test_create_generical_instance_use_remote_webdriver(remote_mock: MagicMock):
def test_get_generical_browser_options():
options = FastRPA().browser_options
assert type(options) is ChromeOptions
assert options.arguments == ['--start-maximized', '--ignore-certificate-errors']
assert options.arguments == [
'--start-maximized',
'--ignore-certificate-errors',
]


@patch('fastrpa.app.Remote', MagicMock())
def test_get_specific_browser_options_class():
fastrpa = FastRPA(options_class=FirefoxOptions)
options = fastrpa.browser_options
assert type(options) is FirefoxOptions
assert options.arguments == [
'--start-maximized',
'--ignore-certificate-errors',
]


@patch('fastrpa.app.Remote', MagicMock())
def test_get_specific_browser_arguments():
fastrpa = FastRPA(browser_arguments=['arg1', 'arg2'])
options = fastrpa.browser_options
assert type(options) is ChromeOptions
assert options.arguments == ['arg1', 'arg2']


@patch('fastrpa.app.Remote', MagicMock())
def test_get_specific_browser_arguments_and_options_class():
fastrpa = FastRPA(
options_class=FirefoxOptions, browser_arguments=['arg1', 'arg2']
)
options = fastrpa.browser_options
assert type(options) is FirefoxOptions
assert options.arguments == ['arg1', 'arg2']


@patch('fastrpa.app.Remote')
def test_webdriver_is_quitting(remote_mock: MagicMock):
quit_mock = MagicMock()
remote_mock.return_value = MagicMock(quit=quit_mock)
fastrpa = FastRPA()
del fastrpa
assert quit_mock.call_count == 1


@patch('fastrpa.app.Remote', MagicMock())
def test_get_web_instance():
fastrpa = FastRPA(timeout=99)
web = fastrpa.web()
assert type(web) is Web
assert web.timeout == 99


@patch('fastrpa.app.Remote', MagicMock())
@patch('fastrpa.app.Web')
def test_get_web_instance_and_browse(web_mock: MagicMock):
browse_mock = MagicMock()
web_mock.return_value = MagicMock(browse=browse_mock)
FastRPA().web('some-url')
assert browse_mock.call_count == 1
assert browse_mock.call_args.args == ('some-url',)

0 comments on commit 64ebeaa

Please sign in to comment.