Skip to main content

Selenium

Tesmon supports Selenium integration for end-to-end testing, allowing you to automate browser interactions seamlessly

info

The driver keyword is special in Tesmon scripts. If you use driver as the variable name for your WebDriver, Tesmon automatically saves the state of this driver across multiple tasks. This feature is useful when you need the browser to remain open and maintain its state between different steps of your test.

Example

Here's a basic example of a Selenium script in Tesmon:

scripts:
seleniumLogin: |
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# Initialize the WebDriver
driver = webdriver.Chrome()

# Navigate to the website
driver.get("http://localhost:33000")

# Wait for the page to load
wait = WebDriverWait(driver, 10)

# Perform login
username = driver.find_element(By.NAME, "email")
username.send_keys("testing@tesmon.io")
password = driver.find_element(By.NAME, "password")
password.send_keys("**********")
login_button = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div[2]/div/form/button')))
login_button.click()