toolium packages

toolium modules

config_driver

config_files

class toolium.config_files.ConfigFiles[source]

Bases: object

set_config_directory(config_directory)[source]

Set directory where configuration files are saved

Parameters:

config_directory – configuration directory path

set_config_log_filename(filename)[source]

Set logging configuration file

Parameters:

filename – logging configuration filename

set_config_properties_filenames(*filenames)[source]

Set properties files used to configure test cases

Parameters:

filenames – list of properties filenames

set_output_directory(output_directory)[source]

Set output directory where log file and screenshots will be saved

Parameters:

output_directory – output directory path

set_output_log_filename(filename)[source]

Set logging output file

Parameters:

filename – logging configuration filename

set_visual_baseline_directory(visual_baseline_directory)[source]

Set visual baseline directory where baseline images will be saved

Parameters:

visual_baseline_directory – visual baseline directory path

config_parser

class toolium.config_parser.ExtendedConfigParser(defaults=None, dict_type=<class 'dict'>, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section='DEFAULT', interpolation=<object object>, converters=<object object>, allow_unnamed_section=False)[source]

Bases: ConfigParser

deepcopy()[source]

Returns a deep copy of config object

Returns:

a copy of the config object

get(section, option, *args, **kwargs)[source]

Get an option value for a given section.

If vars is provided, it must be a dictionary. The option is looked up in vars (if provided), section, and in DEFAULTSECT in that order. If the key is not found and fallback is provided, it is used as a fallback value. None can be provided as a fallback value.

If interpolation is enabled and the optional argument raw is False, all interpolations are expanded in the return values.

Arguments raw, vars, and fallback are keyword only.

The section DEFAULT is special.

static get_config_from_file(conf_properties_files)[source]

Reads properties files and saves them to a config object

Parameters:

conf_properties_files – comma-separated list of properties files

Returns:

config object

get_optional(section, option, default=None)[source]

Get an option value for a given section If the section or the option are not found, the default value is returned

Parameters:
  • section – config section

  • option – config option

  • default – default value

Returns:

config value

getboolean_optional(section, option, default=False)[source]

Get an option boolean value for a given section If the section or the option are not found, the default value is returned

Parameters:
  • section – config section

  • option – config option

  • default – default value

Returns:

boolean config value

has_option(section, option)[source]

Check for the existence of a given option in a given section. If the specified section is None or an empty string, DEFAULT is assumed. If the specified section does not exist, returns False.

items(*args)[source]

Return a list of (name, value) tuples for each option in a section.

All % interpolations are expanded in the return values, based on the defaults passed into the constructor, unless the optional argument raw is true. Additional substitutions may be provided using the vars argument, which must be a dictionary whose contents overrides any pre-existing defaults.

The section DEFAULT is special.

options(section)[source]

Return a list of option names for the given section name.

optionxform(optionstr)[source]

Override default optionxform in ConfigParser to allow case sensitive options

remove_option(section, option)[source]

Remove an option.

set(section, option, *args)[source]

Set an option. Extends RawConfigParser.set by validating type and interpolation syntax on the value.

translate_config_variables(str_with_variables)[source]

Translate config variables included in string with format {Section_option} :param context: behave context :param str_with_variables: string with config variables, i.e. {Driver_type}_{Driver_width} :return: string with translated variables

update_properties(new_properties)[source]

Update config properties values Property name must be equal to ‘Section_option’ of config property

Parameters:

new_properties – dict with new properties values

update_toolium_system_properties(new_properties)[source]

Update config properties values or add new values if property does not exist Property name must be ‘TOOLIUM_[SECTION]_[OPTION]’ and property value must be ‘[Section]_[option]=value’ i.e. TOOLIUM_SERVER_ENABLED=’Server_enabled=true’

Section and option can not be configured in property name because they must be case sensitive and, in Windows, system properties are case insensitive

Parameters:

new_properties – dict with new properties values

driver_wrapper

driver_wrappers_pool

class toolium.driver_wrappers_pool.DriverWrappersPool[source]

Bases: object

Driver wrappers pool

classmethod add_wrapper(driver_wrapper)[source]

Add a driver wrapper to the wrappers pool

Parameters:

driver_wrapper – driver_wrapper instance

classmethod capture_screenshots(name)[source]

Capture a screenshot in each driver

Parameters:

name – screenshot name suffix

classmethod close_drivers(scope, test_name, test_passed=True, context=None)[source]

Stop all drivers, capture screenshots, copy webdriver and GGR logs and download saved videos

Parameters:
  • scope – execution scope (function, module, class or session)

  • test_name – executed test name

  • test_passed – True if the test has passed

  • context – behave context

config_directory = None

folder with configuration files

classmethod configure_common_directories(tc_config_files)[source]

Configure common config and output folders for all tests

Parameters:

tc_config_files – test case specific config files

classmethod configure_visual_directories(driver_info)[source]

Configure screenshots, videos and visual directories

Parameters:

driver_info – driver property value to name folders

classmethod connect_default_driver_wrapper(config_files=None)[source]

Get default driver wrapper, configure it and connect driver

Parameters:

config_files – driver wrapper specific config files

Returns:

default driver wrapper

Return type:

toolium.driver_wrapper.DriverWrapper

classmethod download_videos(name, test_passed=True, maintain_default=False)[source]

Download saved videos if video is enabled or if test fails

Parameters:
  • name – destination file name

  • test_passed – True if the test has passed

  • maintain_default – True if the default driver should not be closed

driver_wrappers = []

driver wrappers list # noqa: RUF012

static get_configured_value(system_property_name, specific_value, default_value)[source]

Get configured value from system properties, method parameters or default value

Parameters:
  • system_property_name – system property name

  • specific_value – test case specific value

  • default_value – default value

Returns:

configured value

static get_default_config_directory()[source]

Return default config directory, based in the actual test path

Returns:

default config directory

classmethod get_default_wrapper()[source]

Returns the default (first) driver wrapper

Returns:

default driver wrapper

Return type:

toolium.driver_wrapper.DriverWrapper

static initialize_config_files(tc_config_files=None)[source]

Initialize config files and update config files names with the environment

Parameters:

tc_config_files – test case specific config files

Returns:

initialized config files object

classmethod is_empty()[source]

Check if the wrappers pool is empty

Returns:

true if the wrappers pool is empty

logs_directory = None

folder to save logs

output_directory = None

folder to save output files

classmethod remove_drivers(maintain_default=False)[source]

Clean drivers list except default if it should be reused. Drivers must be closed before.

Parameters:

maintain_default – True if the default driver should not be removed

classmethod save_all_ggr_logs(test_name, test_passed)[source]

Get all GGR logs of each driver and write them to log files

Parameters:
  • test_name – test that has generated these logs

  • test_passed – True if the test has passed

classmethod save_all_webdriver_logs(test_name, test_passed)[source]

Get all webdriver logs of each driver and write them to log files

Parameters:
  • test_name – test that has generated these logs

  • test_passed – True if the test has passed

classmethod save_all_webdriver_or_ggr_logs(test_name, test_passed, ggr=False)[source]

Get all webdriver or GGR logs of each driver and write them to log files

Parameters:
  • test_name – test that has generated these logs

  • test_passed – True if the test has passed

  • ggr – True if driver should be ggr or selenoid

screenshots_directory = None

folder to save screenshots

screenshots_number = None

number of screenshots taken until now

classmethod stop_drivers(maintain_default=False)[source]

Stop all drivers except default if it should be reused

Parameters:

maintain_default – True if the default driver should not be closed

videos_directory = None

folder to save videos

videos_number = None

number of visual images taken until now

visual_baseline_directory = None

folder to save visual baseline images

visual_number = None

number of videos recorded until now

visual_output_directory = None

folder to save visual report and images

jira

pytest_fixtures

selenoid

class toolium.selenoid.Selenoid(driver_wrapper, **kwargs)[source]

Bases: object

properties.cfg or local-properties.cfg files:

[Capabilities] selenoid___options: {‘enableVideo’: True, ‘enableVNC’: True, ‘enableLog’: True}

[Server] enabled: true –> MANDATORY host: <hostname or ip> –> MANDATORY port: <numeric> –> MANDATORY username: <string> –> MANDATORY password: <string> –> MANDATORY video_enabled: true logs_enabled: true

Comments:

the files are always removed in the selenoid server

download_file(filename, timeout=5)[source]

download a file from remote selenoid and removing the file in the server. request: http://<username>:<password>@<ggr_host>:<ggr_port>/download/<ggr_session_id>/<filename> :param filename: file name with extension to download :param timeout: threshold until the video file is downloaded :return: downloaded file path or None

download_session_log(scenario_name, timeout=5)[source]

download the session log file from remote selenoid, renaming the file to scenario name and removing the log file in the server. GGR request: http://<username>:<password>@<ggr_host>:<ggr_port>/logs/<ggr_session_id> selenoid request: http://<username>:<password>@<ggr_host>:<ggr_port>/logs/<ggr_session_id>.log :param scenario_name: scenario name :param timeout: threshold until the log file is downloaded

download_session_video(scenario_name, timeout=5)[source]

download the execution video file if the scenario fails or the video is enabled, renaming the file to scenario name and removing the video file in the server. GGR request: http://<username>:<password>@<ggr_host>:<ggr_port>/video/<session_id> selenoid request: http://<username>:<password>@<ggr_host>:<ggr_port>/video/<session_id>.mp4 :param scenario_name: scenario name :param timeout: threshold until the video file is downloaded

get_selenoid_info()[source]

retrieve the current selenoid host info request: http://<username>:<password>@<ggr_host>:<ggr_port>/host/<ggr_session_id> :return: dict

get_selenoid_option(option_name)[source]

Get selenoid option value from configured capabilities :param option_name: option name :returns: option value

is_the_session_still_active()[source]

Is the GGR session still active? Associated to a browser and the sessionId Example of GGR status:

{
"browsers": {
    "MicrosoftEdge": {
    "latest": {}
    },
    "android": {
    "8.1": {}
    },
    "chrome": {
    "70.0": {},
    "latest": {
        "test_tef": {
        "count": 1,
        "sessions": [
            {
            "caps": {
                "browserName": "chrome",
                "enableVNC": true,
                "enableVideo": true,
                "platformName": "ANY",
                "screenResolution": "1280x1024x24",
                "browserVersion": "latest",
                "videoName": "selenoide952e551bb9395e16d060f28c54e5d31.mp4",
                "videoScreenSize": "1280x1024"
            },
            "container": "8489205e28c9781472e99c3921a6240de3894a3603ed9e187ad6360b6b013b8b",
            "containerInfo": {
                "id": "8489205e28c9781472e99c3921a6240de3894a3603ed9e187ad6360b6b013b8b",
                "ip": "172.17.0.4"
            },
            "id": "1345506093dfed8dbcef610da476911a228ca315978e5464ae49fb1142bbc49b",
            "screen": "1280x1024x24",
            "vnc": true
            }
        ]
        }
    }
    },
    "firefox": {
    "59.0": {},
    "63.0": {},
    "64.0": {},
    "latest": {}
    },
    "internet explorer": {
    "11": {}
    },
    "safari": {
    "latest": {}
    }
},
"pending": 0,
"queued": 0,
"total": 30,
"used": 1
}

:return boolean (although in case of error in the request will be returned None)

test_cases

visual_test