Locators - Selector Class

Locators is the base class for which location selectors are implemented for a project.

sda.locators

class sda.locators.Locators

Bases: object

The Locators implementation

as_dict()

Return all locators

Example:

from selenium_data_attributes.locators import Locators

# Let's assume the user uses the Locators class to define some locators
# for the elements on their web page.

class SomeLocators(Locators):

    USER_NAME = (By.ID, 'username')
    PASSWORD = (By.ID, 'password')

# If that user wanted to return all locators associated with this class
# i.e. "USER_NAME" and "PASSWORD" and return the values of both
# they'd use 'as_dict'

l = SomeLocators()

l.as_dict()

# Returns
# {'USER_NAME': (By.ID, 'username'), 'PASSWORD': (By.ID, 'password')}
Returns:
Return type:dict
is_locator(attrib=None)

Returns True if the class attribute is a valid locator

Parameters:attrib – Class attribute
Returns:True, if the class attribute is a valid locator
Return type:bool
static is_valid(_by='', path=None)

Returns true if the selenium selector is valid

Parameters:
  • _by (str) – Selenium By locator
  • path (str) – Locator value
Returns:

True, if the selenium selector is valid

Return type:

bool