ElementCache Module sw.cache

Classes

class sw.cache.ElementCache[source]

Creates an object to store WebDriver elements on specific pages so subsequent lookups don’t require scanning the DOM.

Returns:ElementCache (self)
add(url, e, **kwargs)[source]

Add an element to the cache. It is stored by a handle and deleted automatically after a full run.

Parameters:
  • url – The URL of element e.
  • e – The Webelement to be stored.
Kwargs:
  • id (None): Identifier for e on the passed url.
  • type (None): Type of the identifier for e on the passed url.
  • handle (None): (separate from id/type) A handle to identify this element by internally (unique).
Returns:

None

clear()[source]

Clears the internal cache, deleting all cached elements. Typically called after every run of our test function.

Returns:None
get(url, **kwargs)[source]

Gets an element from the internal cache stored on the given url. If it doesn’t exist, returns None.

Parameters:

url – The current url to search the cache for.

Kwargs:
  • id (None): Identifier for the element in the cache, on the passed url.
  • type (None): Type of the identifier for the element in the cache, on the passed url.
  • handle (None): (separate from id/type) A handle to identify this element by internally (unique).
Returns:

WebElement for the cached item if a matching element exists. None if not.

Table Of Contents

Previous topic

Child Module sw.child

Next topic

Utilities Module sw.utils

This Page