A command line tool to obfuscate XPath expressions (replacing any IP sensitive parts)
See the built-in help:
python xpatho.py [text file]
Usage: xpatho.py <path to text file containing XPath expressions> [options]
The options are:
[-e --empty (Do not omit empty XPaths)]
[-h --help]
[-u --unique (Omit duplicates)]
Examples: [Windows]
xpatho.py testData\xpaths_1.txt -u
xpatho.py \data\xpaths_1.txt -u -e
Examples: [Unix/Mac]
xpatho.py ./testData/xpaths_1.txt -u
xpatho.py /data/xpaths_1.txt -u -e
Description | Input | Obfuscated Output |
---|---|---|
XPath with keywords 1 | [red and bright] |
[token_10001 and token_10000] |
XPath with keywords 2 | [red or bright] |
[token_10001 or token_10000] |
Complex XPath 1 | [Part1.StatusPart2Part3_Status/Part4.Status/StatusCode = 'X1'] |
[token_10000.token_10004/token_10001.token_10002/token_10003 = 'X1'] |
- by default, empty XPaths are omitted. See the options for how to override this.
- very short tokens (less than 3 letters) are not obfuscated
See the built-in help:
python xpatho_csv.py [CSV file]
Usage: xpatho_csv.py <path to CSV file containing XPath expressions> <path to output CSV file> [options]
The options are:
[-c --csv_column (If reading a CSV file, specifies which column to read, using a 0-based index)]
[-d --csv_delimiter (If reading a CSV file, specifies the field delimiter)]
[-h --help]
[-o --csv_output_delimiter (The column/field delimiter to use in the output CSV file)]
[-v --verbose (Verbose output to help debug)]
Examples: [Windows]
xpatho_csv.py testData\\xpaths_1.csv temp\\xpaths_1.obfuscated.csv -csv_column 1
xpatho_csv.py \\data\\xpaths_2.csv temp\\xpaths_2.obfuscated.csv -csv_column 1
Examples: [Unix/Mac]
xpatho_csv.py ./testData/xpaths_1.csv temp/xpaths_1.obfuscated.csv -csv_column 1
xpatho_csv.py /data/xpaths_2.csv temp/xpaths_2.obfuscated.csv -csv_column 1
- very short tokens (less than 3 letters) are not obfuscated
See the built-in help:
python xpatho_json.py [JSON file]
Usage: xpatho_json.py <path to JSON file containing XPath expressions> [options]
The options are:
[-h --help]
Examples: [Windows]
xpatho_csv.py testData\\xpaths_1.json
xpatho_csv.py \\data\\xpaths_2.json
Examples: [Unix/Mac]
xpatho_csv.py ./testData/xpaths_1.json
xpatho_csv.py /data/xpaths_2.json
- the path to the location inside the JSON file is hard-coded! So you may need to tweak the Python code, depending on your needs!
- very short tokens (less than 3 letters) are not obfuscated
- Install Python 3.7.x and pip
- Python 3.7.9 or later
- pip 21.3.1 or later
- Install dependencies
pip install -r pip.config
xpatho uses a few nice libraries:
Library | URL | Description |
---|---|---|
parameterized | https://pypi.org/project/parameterized/ | Easily parameterize your unit tests |
Tool | URL | Description |
---|---|---|
pip | https://pypi.org/project/pip/ | pip used with a config file, makes it easy to restore a Python project on another machine (even between Windows and Mac!) |
License is MIT