Skip to main content

The best of Selenium and Cypress in a single Python Package

Project description

Pylenium: Easy Python Web Test Automation

The mission is simple

Bring the best of Selenium, Cypress and Python into one package.

This means:

  • Automatic waiting and synchronization
  • Quick setup to start writing tests
  • Easy to use and clean syntax for amazing readability and maintainability
  • Automatic driver installation so you don't need to manage drivers
  • Leverage the awesome Python language
  • and more!

Test Example

Although Pylenium is a thin wrapper of Selenium, let's use this simple scenario to show the difference between using Selenium and Pylenium:

  1. Visit the QA at the Point website:
  2. Hover the About link to reveal a menu
  3. Click the Leadership link in that menu
  4. Assert Carlos Kidman is on the Leadership page
def test_carlos_is_on_leadership(py):
    assert py.contains('Carlos Kidman')
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from import By
from import expected_conditions as EC
from import WebDriverWait

# define your setup and teardown fixture
def driver():
    driver = webdriver.Chrome()
    yield driver

def test_carlos_is_on_leadership_page_with_selenium(driver):
    wait = WebDriverWait(driver, timeout=10)

    # hover About link
    about_link = driver.find_element(By.CSS_SELECTOR, "a[href='/about']")
    actions = ActionChains(driver)

    # click Leadership link in About menu
    wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "a[href='/leadership'][class^='Header-nav']"))).click()

    # check if 'Carlos Kidman' is on the page
    assert wait.until(lambda _: driver.find_element(By.XPATH, "//*[contains(text(), 'Carlos Kidman')]"))


I teach courses and do trainings for both Selenium and Cypress, but Selenium, out of the box, feels clunky. When you start at a new place, you almost always need to "setup" the framework from scratch all over again. Instead of getting right to creating meaningful tests, you end up spending most of your time building a custom framework, maintaining it, and having to teach others to use it.

Also, many people blame Selenium for bad or flaky tests. This usually tells me that they have yet to experience someone that truly knows how to make Selenium amazing! This also tells me that they are not aware of the usual root causes that make Test Automation fail:

  • Poor programming skills, test design and practices
  • Flaky applications
  • Complex frameworks

What if we tried to get the best from both worlds and combine it with an amazing language?

Selenium has done an amazing job of providing W3C bindings to many languages and makes scaling a breeze.

Cypress has done an amazing job of making the testing experience more enjoyable - especially for beginners.

Pylenium looks to bring more Cypress-like bindings and techniques to Selenium (like automatic waits) and still leverage Selenium's power along with the ease-of-use and power of Python.

Quick Start

The Official Pylenium Docs are the best place to start, but you can quickly get going with the following steps:

1. Install pyleniumio

pip install pyleniumio


pipenv install pyleniumio


poetry add pyleniumio

2. Initialize Pylenium

# execute at your Project Root
pylenium init

This creates three files:

  • - This has the fixtures needed for Pylenium
  • pylenium.json - This is the config file for Pylenium
  • pytest.ini - This is the config file for pytest

By default, Pylenium uses the Chrome browser. You have to install Chrome or update the pylenium.json file to use the browser of your choice.

3. Write a test

Create a directory called tests and then a test file called

Define a new test called test_google_search

def test_google_search(py)

Pylenium uses pytest as the Test Framework. You only need to pass in pyto the function!

Now we can use Pylenium Commands to interact with the browser.

def test_google_search(py):
    assert py.should().contain_title('puppies')

4. Run the Test

This will depend on your IDE, but you can always run tests from the CLI:

python -m pytest tests/

You're all set! You should see the browser open and complete the commands we had in the test :)


Pylenium uses Gitpod to make it easy to work on it from the desktop or browser without having to worry about the setup like having the correct Python version installed after cloning the repo.

💡 With a single click, you can open the repo in your browser, make your changes, then submit a pull request!

  1. If you're new to Gitpod, check out their Getting Started docs to see how to use it
  2. Visit Pylenium's repo and click the Gitpod button to open the repo in a VS Code browser window
  3. Wait for Gitpod to set up the project. You'll see things get setup from the various .gitpod* files at the Project Root
  4. Once complete, create a new branch and start making your changes
  5. When ready, submit a Pull Request!
  6. Reviewers will see your CI pipeline and even be able to open your Gitpod instance if needed - making collaboration much easier
  7. Gitpod instances are ephemeral, so you can create, share, and delete them as needed

🧪 By default, UI tests executed in Gitpod are headless. If you'd like to see UI tests run, open port 6080 from the bottom right corner of VS Code.

For more details and other ways to contribute to Pylenium, visit the doc 👀

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

pyleniumio-1.20.0.tar.gz (37.1 kB view hashes)

Uploaded Source

Built Distribution

pyleniumio-1.20.0-py3-none-any.whl (41.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page