webdriver_test_tools.project.cmd.new module¶
-
webdriver_test_tools.project.cmd.new.main(test_package_path, test_package, args)[source]¶ Command line dialogs for creating a new file
This method checks
argsfor optional arguments for each of its prompts. If these are set to something other thanNone, their corresponding input prompts will be skipped unless validation for that parameter fails.type,module_name, andclass_nameare the 3 values required to create a new file. If these are all set to something other thanNone, this method will default to an emptydescriptionunless one is provided.forceis the only optional parameter that does not have a prompt. It will default toFalseunless the--forceflag is used when calling this method.The
new pagecommand has additional optional arguments--prototypeand--yaml/--no-yaml(depending on the configuration ofProjectFilesConfig.ENABLE_PAGE_OBJECT_YAML). Prompt for--prototypewill not be shown iftype,module_name, andclass_nameare all set to something other thanNone. Instead, this method will use the standard page object template unless one is specified withprototype. Currently there is no prompt for the--yaml/--no-yamlarguments, so the value ofProjectFilesConfig.ENABLE_PAGE_OBJECT_YAMLwill always be used unless--yaml/--no-yamlis specified.- Parameters
test_package_path – The root directory of the test package
test_package – The python package name of the test package
args – Parsed arguments for the
newcommand
-
webdriver_test_tools.project.cmd.new.add_new_subparser(subparsers, config_module, formatter_class=<class 'argparse.RawTextHelpFormatter'>)[source]¶ Add subparser for the
<test_package> newcommand- Parameters
subparsers –
argparse._SubParsersActionobject for the test package ArgumentParser (i.e. the object returned by theadd_subparsers()method)config_module – The module object for
<test_project>.configformatter_class – (Default:
argparse.RawTextHelpFormatter) Class to use for theformatter_classparameter
- Returns
argparse.ArgumentParserobject for the newly addednewsubparser
-
webdriver_test_tools.project.cmd.new.get_new_parent_parser(parents=[], class_name_metavar='<ClassName>', class_name_help='Name to use for the initial class')[source]¶ Returns an
ArgumentParserwith<module_name>,<class_name>, and--descriptionarguments- Parameters
parents – (Optional) List of
ArgumentParserobjects to use as parents for the test argument parserclass_name_metavar – (Optional) Metavar to display for the class_name argument
class_name_help – (Optional) Help text to use for the class_name argument
- Returns
ArgumentParserwith<module_name>,<class_name>, and--descriptionarguments
-
webdriver_test_tools.project.cmd.new.parse_new_args(package_name, tests_module, args)[source]¶ Parse arguments and run the ‘new’ command
- Parameters
package_name – Name of the test package
tests_module – The module object for
<test_project>.tests. Used to determine the filepath of the packageargs – The namespace returned by parser.parse_args()
- Returns
Exit code, 0 if files were created without exceptions, 1 otherwise.
Note
Technically, this will always return 0, as all fail states cause an exception to be raised. This is just to keep it consistent with other project cmd parse arg functions.
-
webdriver_test_tools.project.cmd.new.validate_description(description)[source]¶ Replaces double quotes with single quotes in class description
If the description is
Noneor an empty string, this function considers it valid and returnsNone- Parameters
description – The desired description string
- Returns
Validated description string with double quotes replaced with single quotes or
Noneif the description is empty