webdriver_test_tools.data package

The data subpackage includes some external packages for generating fake user info and placeholder text. For more information, see their documentation pages:

Data Utilities

class randomuser.RandomUser(get_params=None, user_data=None, api_info=None)[source]
__init__(get_params=None, user_data=None, api_info=None)[source]

Initialize RandomUser object

Parameters
  • get_params – (Optional) Dictionary mapping query parameter names to their values. See https://randomuser.me/documentation for details on parameters.

  • user_data – (Optional) If specified, this _data will be used instead of querying the API for user _data. Use in instances where the user _data has already been generated (e.g. restoring user _data, creating multiple users with single call to API using the ‘results’ parameter)

  • api_info – (Optional) If the user is being generated with the user_data parameter, the _info variable will be set to this. Otherwise, it will be ignored when generating a random user.

class PictureSize[source]

Constants for size parameter in RandomUser.get_picture()

LARGE = 'large'
MEDIUM = 'medium'
THUMBNAIL = 'thumbnail'
class Info[source]

Constants for RandomUser._info dictionary keys

SEED = 'seed'
RESULTS = 'results'
PAGE = 'page'
VERSION = 'version'
exception APIError(message)[source]

Exception to raise when the API query returns an error

Documentation on API errors: https://randomuser.me/documentation#errors

get_first_name(capitalize=True)[source]

Returns first name

Parameters

capitalize – (Default = True) Capitalize first letter if True

get_last_name(capitalize=True)[source]

Returns last name

Parameters

capitalize – (Default = True) Capitalize first letter if True

get_full_name(capitalize=True)[source]

Returns first and last name separated by a space

Parameters

capitalize – (Default = True) Capitalize first letter of each name if True

get_gender()[source]

Returns gender

get_dob(parse_time=False)[source]

Returns date of birth as a string in the format ‘%Y-%m-%dT%H:%M:%SZ’ (ISO 8601 standard)

Parameters

parse_time – (Default = False) If True, parse date of birth string using time.strptime() and return the results instead of a string

get_age()[source]

Returns the age of the user

get_nat()[source]

Returns nationality

get_street(capitalize=True)[source]

Returns street address

Parameters

capitalize – (Default = True) Capitalize first letter of words if True

get_city(capitalize=True)[source]

Returns city

Parameters

capitalize – (Default = True) Capitalize first letter of words if True

get_state(capitalize=True)[source]

Returns state

Parameters

capitalize – (Default = True) Capitalize first letter of words if True

get_postcode()[source]

Returns post code

get_zipcode()[source]

Returns zip code (wrapper for get_postcode())

get_coordinates()[source]

Returns a dictionary with keys ‘longitude’ and ‘latitude’ mapped to their respective values

get_phone(strip_parentheses=False, strip_hyphens=False)[source]

Returns phone number as a string in the format ‘(###)-###-####’

Parameters
  • strip_parentheses – (Default = False) Omit parentheses if True

  • strip_hyphens – (Default = False) Omit hyphens if True

get_cell(strip_parentheses=False, strip_hyphens=False)[source]

Returns cell phone number as a string in the format ‘(###)-###-####’

Parameters
  • strip_parentheses – (Default = False) Omit parentheses if True

  • strip_hyphens – (Default = False) Omit hyphens if True

get_email()[source]

Returns email address

get_username()[source]

Returns username

get_password()[source]

Returns password

get_registered(parse_time=False)[source]

Returns registration date as a string in the format ‘%Y-%m-%dT%H:%M:%SZ’ (ISO 8601 standard)

Parameters

parse_time – (Default = False) If True, parse date string using time.strptime() and return the results instead of a string

get_registered_age()[source]

Returns the age (in years) since registration date

get_login_salt()[source]

Returns user login salt

get_login_md5()[source]

Returns user login md5

get_login_sha1()[source]

Returns user login sha1

get_login_sha256()[source]

Returns user login sha256

get_login_uuid()[source]

Returns user login uuid

get_id_type()[source]

Returns the ID type

get_id_number()[source]

Returns the ID number

get_id()[source]

Returns a dictionary mapping ‘type’ to ID type and ‘number’ to ID number

get_picture(size='large')[source]

Returns url to a .jpg of the generated user

Parameters

size – (Default = PictureSize.LARGE) The size of picture to return the url for. Size values are stored as constants in PictureSize nested class.

get_info()[source]

Returns a dictionary with information about the API query

Keys for the info dictionary are stored as constants in Info nested class.

static generate_users(amount, get_params=None)[source]

Returns a list containing the specified amount of randomly generated users.

The Random User Generator API can generate multiple users in a single query instead of connecting once for each user and increasing load on both ends.

Parameters
  • amount – The number of users to generate.

  • get_params – (Optional) Dictionary mapping query parameter names to their values. See https://randomuser.me/documentation for details on parameters.

class loremipsum.ParagraphLength[source]

Bases: object

Constants for the paragraph_length parameter in generate()

OPTIONS = ['short', 'medium', 'long', 'verylong']

List of values for paragraph lengths. Used internally.

SHORT = 0
MEDIUM = 1
LONG = 2
VERY_LONG = 3
classmethod get_option(index)[source]

Returns the string value that corresponds to the constants declared in this class. Used internally.

Parameters

index – One of the constants declared in this class (SHORT, MEDIUM, LONG, VERY_LONG)

Returns

The corresponding string value for the loripsum.net API or None if the index is invalid

loremipsum.HTML_OPTIONS = ['decorate', 'link', 'ul', 'ol', 'dl', 'bq', 'code', 'headers']

Valid keys for html_options

loremipsum.generate(paragraph_count=None, paragraph_length=None, allcaps=False, prude=False, plaintext=True, html_options=None, trailing_newlines=False)[source]

Generate Lorem Ipsum placeholder text using the https://loripsum.net API.

Further documentation of parameters can be found at loripsum.net

Parameters
  • paragraph_count – (Optional) The number of paragraphs to generate. If unspecified, API defaults to 4

  • paragraph_length – (Optional) The average length of a paragraph. Possible values are declared as attributes in loremipsum.ParagraphLength (SHORT, MEDIUM, LONG, VERY_LONG). If unspecified, API defaults to ‘long’

  • allcaps – (Default = False) Use ALL CAPS

  • prude – (Default = False) Prude version. From the API documentation: “The original text contains a few instances of words like ‘sex’ or ‘homo’. Personally, we don’t mind, because these are just common latin words meaning ‘six’ and ‘man’. However, some people (or your clients) might be offended by this, so if you select the ‘Prude version’, these words will be censored.”

  • plaintext – (Default = True) Return plain text, no HTML

  • html_options

    (Default = None) List of html options to specify in request. This will be ignored if plaintext = True. The following options are accepted

    • ’decorate’ - Add bold, italic and marked text.

    • ’link’- Add links.

    • ’ul’ - Add unordered lists.

    • ’ol’ - Add numbered lists.

    • ’dl’ - Add description lists.

    • ’bq’ - Add blockquotes.

    • ’code’ - Add code samples.

    • ’headers’ - Add headers.

  • trailing_newlines – (Default = False) If False, strip trailing new lines in generated text. If True, leave trailing new lines in.

Returns

Result of querying loripsum.net API using the specified options

loremipsum.main()[source]

Prints generated text using parsed args

loremipsum.copy()[source]

Copies generated text using parsed args to clipboard