Selector imitator tries to reconstruct a user selector, changing only fields that the user modified in HTML. It works with the original selector (and its type) and target node (so it should be applied after the best node is already found). It proposes possible healed selectors or raises an error.
Proposed selectors are not guaranteed to find a unique web element. Uniqueness must be checked outside of the service with a selenium driver.
- Example request and response
- Image and container resources consumption
- Installation with Docker
- Creating your own image from Dockerfile
- Local testing
Here is an example request. You can try out different requests with Swagger after the installation.
Run the following command to install and use Healenium selector imitator as a stand-alone service (you'll need docker installed):
docker compose up
Now you can access an API at http://localhost:8000/
Check http://localhost:8000/docs for Swagger documentation.
If you wish to make some changes to the code and test them in Docker environment, you will need to create an image. Run these commands from the repository directory, change the version if needed (you'll need docker and pyarmor installed):
pyarmor obfuscate --platform linux.x86_64.7 --recursive --output dist/src src/__init__.py
pyarmor obfuscate --platform linux.x86_64.7 --exact app.py
docker build -t healenium/hlm-selector-imitator:1 .
docker run -d -p 8000:8000 healenium/hlm-selector-imitator:1
To test or lint locally, create a virtual environment with Pyhton 3.7 and install packages from requirements_dev.txt
Test with pytest:
pytest
Get coverage report:
coverage run -m pytest
coverage report -m
coverage html
Check types with mypy:
mypy src app.py
Lint with flake8:
flake8
Format code with black:
black .