aamras.driver package

Submodules

aamras.driver.cookies module

Cookie management.

class aamras.driver.cookies.CookieManager(file_: str = 'cookies.json')[source]

Bases: aamras.util.logger.LoggerMixin

Loads, maintains, and persists a list of cookie dicts.

add(cookies: Union[Dict, List[Dict]]) → None[source]

Merge cookies into cookie list.

Parameters:cookies – Cookies to be merged in
cookies

Data structure housing cookies.

Mapping of domain -> list of associated cookies.

get() → List[Mapping][source]

Get stored cookies.

save(cookies: Union[Dict, List[Dict], None] = None) → None[source]

Save cookie list to disk.

Parameters:cookies – additional cookie(s) to be added before save
class aamras.driver.cookies.CookieManagerMixin[source]

Bases: object

Mixin providing CookieManger instance as “cookies” attribute.

cookies
aamras.driver.cookies.with_valid_expiry(cookie: Mapping) → Mapping[source]

Convert cookie expiry to milliseconds, if necessary.

Parameters:cookie – Coookie to be converted

aamras.driver.driver module

Driver wrapper.

class aamras.driver.driver.Driver(driver: selenium.webdriver.remote.webdriver.WebDriver)[source]

Bases: aamras.util.logger.LoggerMixin, aamras.driver.cookies.CookieManagerMixin, aamras.driver.element.ElementTraverserMixin

Abstraction/wrapper of selenium WebDriver.

click(id_: Optional[str] = None, name: Optional[str] = None, class_: Optional[str] = None, tag: Optional[str] = None) → None[source]

Click an element matching provided criteria.

See element() for documentation on criteria.

close()[source]

Save cookies and shut down driver.

dom_root
get(url: str) → None[source]

Navigate to a provided url.

Parameters:url – relative or absolute path, or full URL to navigate to
log_page() → None[source]

Write page information to log.

save_source(file_path: str) → None[source]

Save source code of current page.

Parameters:file_path – path of file to save source to
screenshot(file_path: str)[source]

Save a screenshot of the browser window.

Parameters:file_path – path of file to save screenshot to
submit(id_: Optional[str] = None, name: Optional[str] = None, class_: Optional[str] = None, tag: Optional[str] = None) → None[source]

Submit an element matching provided criteria.

See element() for documentation on criteria.

title

Title of the current page.

type(id_: Optional[str] = None, name: Optional[str] = None, class_: Optional[str] = None, text: Optional[str] = None) → None[source]

Send text input to an element matching provided criteria.

See element() for documentation on criteria.

url

Current URL.

aamras.driver.factory module

Driver factory/creation.

class aamras.driver.factory.DriverFactory[source]

Bases: aamras.util.logger.LoggerMixin

create(driver_type: Optional[aamras.driver.factory.DriverType] = None) → aamras.driver.driver.Driver[source]

Construct driver with the provided driver type.

Parameters:driver_type – type of driver to construct.
class aamras.driver.factory.DriverType[source]

Bases: str, enum.Enum

Common driver types.

CHROME = 'chrome'
FIREFOX = 'firefox'
aamras.driver.factory.create(driver_type: Optional[aamras.driver.factory.DriverType] = None)[source]

Construct driver with the provided driver type.

Parameters:driver_type – type of driver to construct.

Module contents

Driver logic and related operations.

aamras.driver.create(driver_type: Optional[aamras.driver.factory.DriverType] = None)[source]

Construct driver with the provided driver type.

Parameters:driver_type – type of driver to construct.
class aamras.driver.Driver(driver: selenium.webdriver.remote.webdriver.WebDriver)[source]

Bases: aamras.util.logger.LoggerMixin, aamras.driver.cookies.CookieManagerMixin, aamras.driver.element.ElementTraverserMixin

Abstraction/wrapper of selenium WebDriver.

click(id_: Optional[str] = None, name: Optional[str] = None, class_: Optional[str] = None, tag: Optional[str] = None) → None[source]

Click an element matching provided criteria.

See element() for documentation on criteria.

close()[source]

Save cookies and shut down driver.

dom_root
get(url: str) → None[source]

Navigate to a provided url.

Parameters:url – relative or absolute path, or full URL to navigate to
log_page() → None[source]

Write page information to log.

save_source(file_path: str) → None[source]

Save source code of current page.

Parameters:file_path – path of file to save source to
screenshot(file_path: str)[source]

Save a screenshot of the browser window.

Parameters:file_path – path of file to save screenshot to
submit(id_: Optional[str] = None, name: Optional[str] = None, class_: Optional[str] = None, tag: Optional[str] = None) → None[source]

Submit an element matching provided criteria.

See element() for documentation on criteria.

title

Title of the current page.

type(id_: Optional[str] = None, name: Optional[str] = None, class_: Optional[str] = None, text: Optional[str] = None) → None[source]

Send text input to an element matching provided criteria.

See element() for documentation on criteria.

url

Current URL.

class aamras.driver.DriverType[source]

Bases: str, enum.Enum

Common driver types.

CHROME = 'chrome'
FIREFOX = 'firefox'
class aamras.driver.DriverFactory[source]

Bases: aamras.util.logger.LoggerMixin

create(driver_type: Optional[aamras.driver.factory.DriverType] = None) → aamras.driver.driver.Driver[source]

Construct driver with the provided driver type.

Parameters:driver_type – type of driver to construct.
class aamras.driver.Element(element: selenium.webdriver.remote.webelement.WebElement)[source]

Bases: aamras.util.logger.LoggerMixin, aamras.driver.element.ElementTraverserMixin

Wrapper for selenium WebElement.

attribute(name: str) → Optional[str][source]
class_
clear() → None[source]

Clear element’s text, if present.

click() → None[source]

Click the element.

description
displayed
dom_root
enabled
id
name
screenshot(file_path: str) → None[source]

Save screenshot of element.

Parameters:file_path – path of file to save screenshot to
selected
submit() → None[source]

Submit the element.

tag
text
type(text: Optional[str]) → None[source]

Send text input to the element.