arjuna.tpi.config module

Provides configuration related public classes.

Provides the Configuration and ConfigBuilder classes.

Configuration class represents the immutable, read-only configuration object.

ConfigBuilder can be used to create new configuration from an existing one.

class arjuna.tpi.config.ConfigBuilder(*, base_config: arjuna.tpi.config.Configuration, auto_name_gen=True, _conf_stage=ConfigStage.CODED)

Bases: object

Helps in constructing a new Configuration object from an existing one.

Keyword Arguments
  • base_config – Parent configuration to be used be used as reference for creation of the new Configuration object.

  • auto_gen_name – Generate a unique configuration name in build call if name is not provided. Default is True.

Note

It is not meant to be directly constructed. Use builder method of a Configuration object to create the associated ConfigBuilder object.

Note

You can also use . notation or [] dict notation to add/update an option value.

builder.option = value
builder[option] = value
app(path) self

(Not supported yet) Configure path for mobile app installer.

Parameters

path – Absolute path of mobile app on test machine.

Returns

Current ConfigBuilder object

appium(context) self

(Not supported yet) Configure Appium as the automation engine.

Returns

Current ConfigBuilder object

chrome() self

Configure Chrome as the browser.

Returns

Current ConfigBuilder object

firefox() self

Configure Firefox as the browser.

Returns

Current ConfigBuilder object

from_file(fpath) self

Add all options from a .conf file.

Parameters

fpath – Path of .conf file.

Returns

Current ConfigBuilder object

Note

If instead of full absolute path, a name or relative file path is provided, Arjuna creates the path in relation to the default configuration directory - <Project Root>/config.

option(option: arjuna.tpi.arjuna_types.ArjunaOptionOrStr, obj: Any) self

Add/Change option value.

Parameters
  • option – An ArjunaOption or a string representing ArjunaOption or a user defined option.

  • obj – An object of any type as per the option key.

Returns

Current ConfigBuilder object

options(option_map: Dict[arjuna.tpi.arjuna_types.ArjunaOptionOrStr, Any]) self

Add/Change multiple option values.

Parameters

option_map – A dictionary of options. Keys are ArjunaOptions or strings and values can be of any type as per the option key.

Returns

Current ConfigBuilder object

register(*, config_name=None)

Register the new configuration.

Keyword Arguments

config_name – (Optional) Name that you want to assign to the configuration.

Note

  • Name needs to be unique in a test run. No configuration should exist with the same name.

  • A dynamic, unique name is generated if name is not provided.

selenium() self

Configure Selenium as the automation engine.

Returns

Current ConfigBuilder object

class arjuna.tpi.config.Configuration(test_session: TestSession, name: str, config: WrappedConfiguration)

Bases: object

Read-only, immutable object that contains a fixed mapping of ArjunaOptions and User defined options.

Parameters
  • test_session – Current test session object.

  • name – Name of this configuration.

  • config – WrappedConfiguration object. Configuration provides a read-only interface on top of it.

Note

  • You never directly create a Configuration object.

  • It is an outcome of configuration processing that Arjuna does.

Note

  • The option name string is considered by Arjuna as case-insensitive. Also, . (dot) and _ (underscore) are interchangeable. So, following are equivalent arguments
    • ArjunaOption.BROWSER_NAME

    • BROWSER_NAME

    • BrOwSeR_NaMe

    • browser.name

    • Browser.Name

    • and so on

Note

You can also use . notation or [] dict notation to retrieve an option value.

config.option
config[option]
as_dict() Dict[str, Any]

Get all options.

Returns

A dictionary of all Arjuna Options and User Defined Options

property builder: arjuna.tpi.config.ConfigBuilder

Creates a configuration builder object which takes this configuration as its reference.

Returns

new ConfigBuilder object

get_arjuna_options_as_map() Dict[arjuna.tpi.arjuna_types.ArjunaOptionOrStr, Any]

Get all Arjuna options.

Returns

A dictionary of all Arjuna Options.

is_arjuna_option_not_set(option) bool

Check if the value for an Arjuna option was set. (Checks for ‘not_set’ string.)

Parameters

option – An ArjunaOption or a string representing ArjunaOption or a user defined option.

Returns

True/False

property name: str

Name of this configuration object.

Returns

Name of this configuration

property test_session: TestSession

Test Session object for this Configuration.

value(option: arjuna.tpi.arjuna_types.ArjunaOptionOrStr) Any

Get the value of a configuration option.

Parameters

option – An ArjunaOption or a string representing ArjunaOption or a user defined option.

Returns

Object of any type, depending on the option.