# loadero-py-testui-commands [](https://pypi.org/project/loadero-py-testui-commands/)
## Installation
Installation is as simple as adding this line to your requirements.txt
(or equivalent) file.
```bash
loadero-py-testui-commands
```
After which you will be able to install all of the dependencies using pip.
```bash
pip install -r requirements.txt
```
The latest tag always will be the most up-to-date version when compared to the
commands used in the Loadero environment.
## Usage
These Py-TestUI custom commands were made to simplify local script development
for usage in the Loadero environment. By using these commands, you can write your
Loadero script locally and then upload it to Loadero. This also allows for more
rapid development because the script can be debugged and run locally.
To use the commands in your tests, you need to download this dependency to your
project (as shown in above) and then only import the functions in your
script file. Keep in mind, that when migrating the script to Loadero, you do not
need to import the functions there as-well, that will be done automatically.
This is how you can import the functions in your script file:
```py
from commands.receive_email import gen_email, receive_email
from commands.ignore_alert import ignore_alert
from commands.set_file import set_file
from commands.set_request_header import set_request_header
from commands.set_user_agent import set_user_agent
from commands.time_execution import time_execution
from commands.update_network import update_network
from commands.wait_for_download_finished import wait_for_download_finished
```
After which they can be used in your script file as any other function.
Script example:
```py
def test_on_loadero(driver: TestUIDriver):
really_long_pause = 300
driver.navigate_to("https://duckduckgo.com/")
def locate_search_bar():
e(
driver, "css", "#searchbox_input"
).wait_until_visible().send_keys("QA Processes")
e(driver, "css", "[aria-label='Search']").wait_until_visible().click()
e(driver, "css", "#r1-0 > div > h2").wait_until_visible()
time.sleep(really_long_pause)
# Example of timing execution without specifying a timeout.
time_execution("locate_search_bar", locate_search_bar)
```
Not all commands behave the same way as they do in the Loadero environment.
Some of them are modified to work in a local environment, such as
`update_network` and `set_request_header`.
## Commands
The following table shows all available commands and whether there are any
changes to how they function in a local environment.
Full descriptions for how each function behaves in Loadero and their usage can
be found in [Loadero wiki](https://wiki.loadero.com/docs/testui-python/custom-commands/)
page. To see the differences between local and Loadero environment, you can
compare the descriptions in the wiki to the differences mentioned in this README.
| Command | Differences |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `gen_email` | Full email or only first part can be provided, if only the first part is provided then `@mailinator.com` is appended |
| `ignore_alert` | No differences |
| `receive_email` | By default an empty array will be returned, but `emails.json` file can be saved in the working directory which will contain all of the emails |
| `set_file` | Any local file can be used, Loadero constant can be used if the same file name is used |
| `set_request_header` | No request header will be set |
| `set_user_agent` | User agent won't be changed |
| `time_execution` | Execution time will be logged, but not saved |
| `update_network` | Network settings will not be updated |
| `wait_for_download_finished` | Function will finish instantly and not wait for download to be finished |
The `emails.json` file should be located in the directory from which you will be
running the tests and should have the following structure:
```json
{
"emails": [
{
"from": "email_from",
"to": "email_to",
"headers": {
"header1": "header_value"
},
"subject": "email_subject",
"text/html": "html body",
"text/plain": "plain text body"
}
]
}
```
To simulate a more realistic environment, you can modify the `emails.json` file
mid-run to add additional emails to the array. The file will be read every time
the `receive_email` command is called.
Raw data
{
"_id": null,
"home_page": "https://github.com/loadero/loadero-py-testui-commands",
"name": "loadero-py-testui-commands",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6, <4",
"maintainer_email": "",
"keywords": "loadero",
"author": "Loadero Team",
"author_email": "support@loadero.com",
"download_url": "https://files.pythonhosted.org/packages/7c/c2/a3f0f799d757e198340f1ef9702385f5fb9936bc364c79b932079720c9a0/loadero-py-testui-commands-1.1.0.tar.gz",
"platform": null,
"description": "# loadero-py-testui-commands [](https://pypi.org/project/loadero-py-testui-commands/)\n\n## Installation\n\nInstallation is as simple as adding this line to your requirements.txt\n(or equivalent) file.\n\n```bash\nloadero-py-testui-commands\n```\n\nAfter which you will be able to install all of the dependencies using pip.\n\n```bash\npip install -r requirements.txt\n```\n\nThe latest tag always will be the most up-to-date version when compared to the\ncommands used in the Loadero environment.\n\n## Usage\n\nThese Py-TestUI custom commands were made to simplify local script development\nfor usage in the Loadero environment. By using these commands, you can write your\nLoadero script locally and then upload it to Loadero. This also allows for more\nrapid development because the script can be debugged and run locally.\n\nTo use the commands in your tests, you need to download this dependency to your\nproject (as shown in above) and then only import the functions in your\nscript file. Keep in mind, that when migrating the script to Loadero, you do not\nneed to import the functions there as-well, that will be done automatically.\n\nThis is how you can import the functions in your script file:\n\n```py\nfrom commands.receive_email import gen_email, receive_email\nfrom commands.ignore_alert import ignore_alert\nfrom commands.set_file import set_file\nfrom commands.set_request_header import set_request_header\nfrom commands.set_user_agent import set_user_agent\nfrom commands.time_execution import time_execution\nfrom commands.update_network import update_network\nfrom commands.wait_for_download_finished import wait_for_download_finished\n```\n\nAfter which they can be used in your script file as any other function.\nScript example:\n\n```py\ndef test_on_loadero(driver: TestUIDriver):\n really_long_pause = 300\n driver.navigate_to(\"https://duckduckgo.com/\")\n\n def locate_search_bar():\n e(\n driver, \"css\", \"#searchbox_input\"\n ).wait_until_visible().send_keys(\"QA Processes\")\n e(driver, \"css\", \"[aria-label='Search']\").wait_until_visible().click()\n e(driver, \"css\", \"#r1-0 > div > h2\").wait_until_visible()\n time.sleep(really_long_pause)\n\n # Example of timing execution without specifying a timeout.\n time_execution(\"locate_search_bar\", locate_search_bar)\n```\n\nNot all commands behave the same way as they do in the Loadero environment.\nSome of them are modified to work in a local environment, such as\n`update_network` and `set_request_header`.\n\n## Commands\n\nThe following table shows all available commands and whether there are any\nchanges to how they function in a local environment.\n\nFull descriptions for how each function behaves in Loadero and their usage can\nbe found in [Loadero wiki](https://wiki.loadero.com/docs/testui-python/custom-commands/)\npage. To see the differences between local and Loadero environment, you can\ncompare the descriptions in the wiki to the differences mentioned in this README.\n\n| Command | Differences |\n| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |\n| `gen_email` | Full email or only first part can be provided, if only the first part is provided then `@mailinator.com` is appended |\n| `ignore_alert` | No differences |\n| `receive_email` | By default an empty array will be returned, but `emails.json` file can be saved in the working directory which will contain all of the emails |\n| `set_file` | Any local file can be used, Loadero constant can be used if the same file name is used |\n| `set_request_header` | No request header will be set |\n| `set_user_agent` | User agent won't be changed |\n| `time_execution` | Execution time will be logged, but not saved |\n| `update_network` | Network settings will not be updated |\n| `wait_for_download_finished` | Function will finish instantly and not wait for download to be finished |\n\nThe `emails.json` file should be located in the directory from which you will be\nrunning the tests and should have the following structure:\n\n```json\n{\n \"emails\": [\n {\n \"from\": \"email_from\",\n \"to\": \"email_to\",\n \"headers\": {\n \"header1\": \"header_value\"\n },\n \"subject\": \"email_subject\",\n \"text/html\": \"html body\",\n \"text/plain\": \"plain text body\"\n }\n ]\n}\n```\n\nTo simulate a more realistic environment, you can modify the `emails.json` file \nmid-run to add additional emails to the array. The file will be read every time\nthe `receive_email` command is called.\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "PyTestUI commands for Loadero scripts",
"version": "1.1.0",
"project_urls": {
"Homepage": "https://github.com/loadero/loadero-py-testui-commands",
"Loadero": "https://loadero.com/",
"Source": "https://github.com/loadero/loadero-py-testui-commands",
"Tracker": "https://github.com/loadero/loadero-py-testui-commands/issues"
},
"split_keywords": [
"loadero"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fa976044abca66623a419f96223a1ebc9cc91ce6689c3097917a2a7e67a0ea3c",
"md5": "e86dc01573f17accd47a56e5c9340e82",
"sha256": "a12ff79e73b7081ca5a0dd12e439a33291ca2af64cfab8f65c896f2267953afc"
},
"downloads": -1,
"filename": "loadero_py_testui_commands-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e86dc01573f17accd47a56e5c9340e82",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6, <4",
"size": 7205,
"upload_time": "2023-12-14T12:17:31",
"upload_time_iso_8601": "2023-12-14T12:17:31.669635Z",
"url": "https://files.pythonhosted.org/packages/fa/97/6044abca66623a419f96223a1ebc9cc91ce6689c3097917a2a7e67a0ea3c/loadero_py_testui_commands-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7cc2a3f0f799d757e198340f1ef9702385f5fb9936bc364c79b932079720c9a0",
"md5": "f8ce1abfa0606387abbf013659d4c990",
"sha256": "e190995d379877730830409ea35a489ed2114209d17c8e5a026b1659d0ea93f7"
},
"downloads": -1,
"filename": "loadero-py-testui-commands-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "f8ce1abfa0606387abbf013659d4c990",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6, <4",
"size": 5704,
"upload_time": "2023-12-14T12:17:32",
"upload_time_iso_8601": "2023-12-14T12:17:32.606987Z",
"url": "https://files.pythonhosted.org/packages/7c/c2/a3f0f799d757e198340f1ef9702385f5fb9936bc364c79b932079720c9a0/loadero-py-testui-commands-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-14 12:17:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "loadero",
"github_project": "loadero-py-testui-commands",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "loadero-py-testui-commands"
}