UI map parser.
Project description
Library that helps you with storing ui elements in files
HOWTO Install:
pip install ui-map-parser
HOWTO Use:
First you should create a folder where you will store ini files with selectors. In this folder create common.ini file. Now you can create elements in this file or create another ini files which will represent pages.
Example of common.ini:
[DEFAULT]
type=xpath
[SimpleXpathElement]
selector=//div
[SimpleCssElement]
type=css
selector=div#some-id
Example of how you can access this elements:
from ui_map_parser import UIMapParser
# common is page by default but you can change it specifying default_page variable during initialization
ui_map_parser = UIMapParser(ini_files_folder)
selector_type, selector = ui_map_parser.parse_element('SimpleXpathElement') # name of element is case insensitive
# selector_type will be equal to "xpath", selector will be equal to "//div"
You can add another page for example login.ini:
[DEFAULT]
type=xpath
[EmailTextField]
selector=//div[@id="login-panel"]/input[@id="email"]
[PasswordTextField]
selector=//div[@id="login-panel"]/input[@id="password"]
and then access it in following way:
selector_type, selector = ui_map_parser.parse_element('Login.EmailTextField')
You can replace repeating sections such as "//div[[@id="login-panel"]" by using "parent" property:
[DEFAULT]
type=xpath
[LoginPanel]
selector=//div[@id="login-panel"]
[EmailTextField]
parent=Login.LoginPanel
selector=/input[@id="email"]
[PasswordTextField]
parent=Login.LoginPanel
selector=/input[@id="password"]
parent=Login.LoginPanel
indicates that we are searching for parent element in login.ini file with name "LoginPanel".
In case if parent element located in "default_page" (common.ini by default) you can skip this and use without specifying page parent=LoginPanel
.
Important note: you can use parent only on elements with same type
To work with more complex elements templates are supported, you can specify template in your selector:
[RegionButtonTemplate]
type=xpath
selector=//input[@id="region-%%region%%-button"]
and then use it like:
selector_type, selector = ui_map_parser.parse_element('Login.RegionButtonTemplate', template={'region': 'na'})
# selector will be equal to "//input[@id="region-na-button"]"
Also you can specify selectors for different languages:
[SomeElement]
type=xpath
selector=//div
en=[text()="some en text"]
es=[text()="some es text"]
and then specify language when initializing UIMapParser:
ui_map_parser = UIMapParser(ini_files_folder, language='en')
selector_type, selector = ui_map_parser.parse_element('SomeElement')
# selector will be equal to "//div[text()="some en text"]"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ui-map-parser-1.0.0.tar.gz
.
File metadata
- Download URL: ui-map-parser-1.0.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 645704095c3fb055e8e4193207c0a351c82e54993be05ab1e07a16bac97d0694 |
|
MD5 | 5139a4bc1eeac8bb2b3b407c59916804 |
|
BLAKE2b-256 | e6db18ac6271677339b1914529e88119ca9dc417e0d32ea212239165b91bd2f9 |
File details
Details for the file ui_map_parser-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: ui_map_parser-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27e1af52fd725baaaecd7734b16f5f24fbc1e3e8f8dd9dfded129d8b95f2dd16 |
|
MD5 | 34fc5fce71ede06fe38181cfbb962015 |
|
BLAKE2b-256 | 828998f132c9649e7552ccc7b1f05051d932242ddeda0f640c9a41bb106fc10f |