anna-lib
The purpose of this package is to simplify the use of selenium.
requirements
installation
$ pip install anna-lib
usage
from anna_lib.selenium import driver, events, assertions
result = []
firefox = driver.create(driver='firefox', headless=True)
firefox.get('http://example.com/')
events.click(driver=firefox, target='a[href="http://www.iana.org/domains/example"]')
result.append(assertions.current_url_is(firefox, 'http://www.iana.org/domains/example'))
driver
Use this module to create a webdriver based on a set of options:
| param | type | required | values | default value |
|---|---|---|---|---|
| driver | string | yes | 'firefox' or 'chrome' for now | 'firefox' |
| headless | bool | no | True or False | False |
| resolution | tuple | no | (width, height) | (1920, 1080) |
events
Use this module to interact with pages. Each event takes a driver, a target & a timeout which defaults to 16 seconds, with the exception being send_keys which also requires a value.
The target is treated as a css selector unless it starts with '$xpath', in which case it is of course treated as an xpath selector.
from anna_lib.selenium import events, driver
firefox = driver.create('firefox', headless=True)
events.click(driver=firefox, target='#search')
events.send_keys(driver=firefox, target='#search', value='search terms')
events.submit(driver=firefox, target='#search')
events.hover(driver=firefox, target='$xpath//div.result/a')
events.scroll_to(driver=firefox, target='#thing')
events.switch_to(driver=firefox, target='iframe')
assertions
Use this module to check the state of a page, be it by the url or by the page's elements. Each assertion takes a driver, some input & a timeout parameter which defaults to 16 seconds.
from anna_lib.selenium import assertions, driver
firefox = driver.create('firefox', headless=True)
try:
assertions.url_equals(driver=firefox, expected='about:blank')
assertions.in_url(driver=firefox, part='blank')
assertions.element_exists(driver=firefox, target='body')
except ValueError as e:
print(str(e))
except TypeError as e:
print(str(e))
Release files for anna-lib 0.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| anna_lib-0.0.13.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| anna_lib-0.0.13-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.8 kB
Release files / anna_lib-0.0.13.tar.gz
| Download URL | anna_lib-0.0.13.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a67c876c6c2c591babe0c38f5a7e2f4f1faac73f3986997b29eeea6c50670d1
|
|
BLAKE2b-256 checksum How to use checksums |
ce2878e5f4e7ca6733556437952a7024595805166c59e2153d0b097a052c91aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4
|
Release files / anna_lib-0.0.13-py3-none-any.whl
| Download URL | anna_lib-0.0.13-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d7e10f261636c8b3250b50af79250e049c25ce0756f62e78cf9f028f4e873362
|
|
BLAKE2b-256 checksum How to use checksums |
7434bc16d90cbc489baed4cb05859eaeb7277e6e6bd51c872b0ed3496332d031
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4
|