Package: xpath-localizer
Xpath Localizer Packagexpath localizer contains the following tools which help you to internationalize
various web UI automation frameworks such as robotFramework and playwright, or any
automation tools that use the XPATH for the web element locator.xploc commandxploc`commandthis is a testrobotLocalizationrobotLocalizationcommand is to be used with Variabes statement in the robot frame work.
It providesget_variablesfunction and loads variables from specified properties files.A python command (xploc) to localize properties files containing XPATH specification.A python library (xploc) to load localized strings using a BCP-47 compliant language fallback.A python command (robotLocalization) to loadvariablesfrom localized properties files
with the robot Variables statement.InstallationrobotLocalization can be installed with pip/pipenv:pipinstallxpath-localizerpipenvinstallxpath-localizerUsage in robotFrameworkrobotLocalization is used to provide aget_variablesfunction in the robotFramework.
The get_variables function can be used in the robot test case to load strings from
properties files by providing a language fallback mechanism.# resources/sample.propertiesmsg=Hello, World!# resources/sample_ja.propertiesmsg=みなさん、こんにちは!#   sample.robot
#
#   $ robot --variable language:en sample.robot
#   $ robot --variable language:ja sample.robot
#*** Settings ***LibrarySeleniumLibraryVariablesrobotLocalization${LANGUAGE}resources/sample.propertiesverbose=True*** Variables ***${LANGUAGE}en# default LANGUAGE.  This can be replaced by --variable option.*** Test Cases ***Test Case 1[Documentation]robotLocalization SampleLog To Console${msg}Log VariablesGetting variables from get_variables functionrobotLocalization providesget_variabesfunction which can be specified
in the robot Variables statement.Syntax in robot testVariablesrobotLocalizationlocaleIdpath or file listpathOptionslocaleIdspecifies the locale or language of the properties being used.  It is used
to load strings from properties files in properties files in the specified path list
or files.  If the specified locale is not available, English properties will be used.pathOptionsverbose=            True or False
filetype=           file typeExamplesVariablesrobotLocalizationen   ${PROJECT_REPO_PATH}Accessing variables from robot code.Internationalization Helper CLIThe xploc command helps testers to internationalize robot test cases.xplocoperandfile_patternslanguage-listAnalyze ModeIn the analyze mode, xploc CLI reports the localizable strings in the robot test and
candidates of available strings in existing properties files from properties files in the
specified path list.xploc[*pathlist()]--analyze[*robot_file*]--analyzeSpecifies a robot test case.  Typically, this robot file contains Xpath specifications
with UI elements or robot variable specifications used in other keywords.Extract Mode (robotFramework)The extract mode is used to extract strings from a specified robot file.
It also generates internationalized robot files by replacing localizable strings
with variables references.--extract (robotFramework)Specifies a robot test case to extract strings.--output_bundle | –outbSpecifies a bundle file that can be used to store product properties into a single file.
This option is only valid if–use_bundleoption is enabled.--output_properties | –outpSpecifies a properties file to store localizable strings. If–use_bundleis specified,
only strings not available in product properties files are stored.--output_robot | –outr (robotFramework)Specifies a robot file by internationalizing the robot file specified with –extract option.
All localizable strings will be replaced by variable references.  A string with “# i18n:OK ”
comments are ignored.--use_bundle | –use_keys–use_bundle option checks the availability of strings in the specified product properties files.
If found, it uses strings there.--multi_trans--multi_trans options checks the translated value for locales specified with –bundle_locale option
and checks the multiple translations.   If a variant translation is found, it extends the xpath expression
to use “OR” condition to check against all of the variant translations.--playwright (robotFramework)--playwright option checks the xpath specification for Playwright when externalizing the robot
variables.  This option is useful when a robotFramework is used with the Playwright for Python.--xpath (playwright|pytest)--xpath options specified that the specified files contain XPATH strings only.  This option is useful
to create a properties file from an XPATH file.  The XPATH file is usually generated by using a
test automation framework that uses XPATH expression when locating web elements.Dump Mode--dump--dump option generates a list of all the variables loaded from properties files.