πScript with Standalone Pylenium
How to use Pylenium in a regular script instead of in a test
Setup
Pylenium needs two things in order to be instantiated:
PyleniumConfig
Pylenium
Create a main.py file and add the necessary imports:
from pylenium.driver import Pylenium
from pylenium.config import PyleniumConfigCreate an instance of PyleniumConfig
Start by creating an instance of PyleniumConfig. Leaving it blank will create a config with default values. NOTE: This does not use pylenium.json
from pylenium.driver import Pylenium
from pylenium.config import PyleniumConfig
config = PyleniumConfig()To use pylenium.json, you'd have to read the file first:
import json
from pylenium.driver import Pylenium
from pylenium.config import PyleniumConfig
with open("pylenium.json") as file:
pylenium_json = json.load(file)
config = PyleniumConfig(**pylenium_json)You can set config values directly in the script - mixing and matching as needed
Create an instance of Pylenium
Once the config is ready, instantiate Pylenium with it:
Write your Script
You now have access to Pylenium's many commands to script what you need:
Run your Script
Use python to execute main.py
Last updated