- Python (3.12 or higher)
- Docker
Make sure the lib is installed:
pip install infrasonar_seleniumStart Selenium:
docker run -d \
-p 4444:4444 \
-p 7900:7900 \
--shm-size="2g" \
ghcr.io/infrasonar/seleniumNote: We prefer the default image as it mirrors the InfraSonar setup. However, you can use a different image like
selenium/standalone-chromeif needed.
Write a test: (for example, save the following to mytest.py)
from infrasonar_selenium import TestBase
from selenium import webdriver
from selenium.webdriver.common.by import By
class MyTest(TestBase):
description = 'Example test'
url = 'https://www.selenium.dev/selenium/web/web-form.html'
version = 'v0'
@classmethod
def test(cls, driver: webdriver.Remote):
title = driver.title
assert title == "Web form"
driver.implicitly_wait(0.5)
text_box = driver.find_element(by=By.NAME, value="my-text")
submit_button = driver.find_element(by=By.CSS_SELECTOR, value="button")
text_box.send_keys("Selenium")
submit_button.click()
message = driver.find_element(by=By.ID, value="message")
value = message.text
assert value == "Received!"
export = MyTest
if __name__ == '__main__':
MyTest().print_run() # Prints the outputStart the test:
python mytest.pyWith the following link you can view your scripts in action:
http://localhost:7900/?autoconnect=1&resize=scale&password=secret
The same applies for scripts running with InfraSonar, except replace
localhostwith your appliance server address.
For a password or secret in your script, use the following:
from infrasonar_selenium import get_password, get_secret
password = get_password()
secret = get_secret()Next, start the script:
PASSWORD=myPassword SECRET=mySecret python mytest.pyFor InfraSonar, you can provide the probe with the password and/or secret.
InfraSonar encrypts those and they will never leave your appliance.