-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add RPA integration examples and tests (#71)
* Add RPA integration examples and tests * Add RPA integration examples and tests * Refactor RPA integration examples and tests * Refactor RPA integration examples and tests * Refactor RPA integration tests and add pytest marker * Refactor RPA integration tests and examples * Refactor RPA integration: Remove unused local helper functions
- Loading branch information
Showing
4 changed files
with
73 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,18 @@ | ||
from guara.transaction import AbstractTransaction | ||
|
||
|
||
class SubmitTextRPA(AbstractTransaction): | ||
""" | ||
Submits text using RPA for Python | ||
Args: | ||
text (str): The text to be submitted | ||
""" | ||
|
||
def __init__(self, driver): | ||
super().__init__(driver) | ||
|
||
def do(self, text): | ||
self._driver.init() | ||
self._driver.type(text) | ||
self._driver.keyboard("[enter]") |
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,29 @@ | ||
from guara.transaction import AbstractTransaction | ||
|
||
|
||
class OpenApplication(AbstractTransaction): | ||
""" | ||
Opens an application using RPA for Python | ||
Args: | ||
app_path (str): the path to the application executable. | ||
""" | ||
|
||
def __init__(self, driver): | ||
super().__init__(driver) | ||
|
||
def do(self, app_path): | ||
self._driver.init() | ||
self._driver.run(app_path) | ||
|
||
|
||
class CloseApplication(AbstractTransaction): | ||
""" | ||
Closes an application using RPA for Python | ||
""" | ||
|
||
def __init__(self, driver): | ||
super().__init__(driver) | ||
|
||
def do(self): | ||
self._driver.close() |
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,24 @@ | ||
import rpa as r | ||
import pytest | ||
from guara.transaction import Application | ||
from guara import it | ||
from examples.linux_desktop.rpa_python import setup | ||
from examples.linux_desktop.rpa_python import home | ||
|
||
|
||
@pytest.mark.skip(reason="Complex setup in CI environment") | ||
class TestRPAIntegration: | ||
""" | ||
TestRPAIntegration is a test class for integrating RPA for Python with a local application. | ||
""" | ||
|
||
def setup_method(self, method): | ||
self._app = Application(r) | ||
self._app.at(setup.OpenApplication, app_path="path/to/application.exe") | ||
|
||
def teardown_method(self, method): | ||
self._app.at(setup.CloseApplication) | ||
|
||
def test_submit_text(self): | ||
text = "Hello, RPA for Python!" | ||
self._app.at(home.SubmitTextRPA, text=text).asserts(it.IsEqualTo, text) |
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 |
---|---|---|
|
@@ -17,3 +17,5 @@ pyautogui | |
opencv-python | ||
dogtail | ||
splinter | ||
rpa | ||
|