Skip to main content

selenium interface

Project description

anna-lib

The purpose of this package is to simplify the use of selenium.

requirements

selenium

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))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anna_lib-0.0.9.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anna_lib-0.0.9-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file anna_lib-0.0.9.tar.gz.

File metadata

  • Download URL: anna_lib-0.0.9.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for anna_lib-0.0.9.tar.gz
Algorithm Hash digest
SHA256 0850078647f87d5ec5e37767fff73f62236934423e8e4350a78d711015a2c65a
MD5 2d79bfd521e3784d5540a60a91dc4fea
BLAKE2b-256 c0906e5e85eb377dc6cdb5ad1df64dd7df33f4274ef05054b48c14fbb72c6903

See more details on using hashes here.

File details

Details for the file anna_lib-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: anna_lib-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for anna_lib-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 f8e6389a449952c2bcd14e0a17d135577b0ef8af7a0558b1abd16ab3a7bb1006
MD5 2328742e1c7874a58a4a62a5159a6e8b
BLAKE2b-256 17c8756bd420314f3342c1f47e12a4a8b10b27dc894c79ef75e790a0714503eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page