For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content

Selenium With Python


Run your Python Selenium tests on the TestMu AI cloud grid across 10,000+ browser/device combinations. The setup is the same for every framework: you connect to the grid and pass your capabilities. This guide covers that shared flow once, then gives you a per-framework quickstart in the tabs below.

Prerequisites​


Complete these steps before running your first Python Selenium test.

  1. Install the latest Python build from the official website.

  2. Verify that pip is installed in your system. Install pip from pip documentation.

  3. Download the latest Selenium Client and its WebDriver bindings from the official website.

  4. Create a TestMu AI account if you don't have one.

  5. Get your Username and Access Key from the TestMu AI Dashboard.

  6. Install Python and pip.

  7. Install the Selenium client and WebDriver bindings, and (recommended) virtualenv to isolate dependencies.

To create and activate a virtual environment on macOS or Linux:

Verified
pip install virtualenv
virtualenv venv
source venv/bin/activate

On Windows, activate it with venv\Scripts\activate instead.

Set Your Credentials​


Clone the repository and install dependencies.

Set TestMu AI Username and Access Key in environment variables.

git clone https://github.com/LambdaTest/python-selenium-sample
cd python-selenium-sample

Install the Selenium driver using pip:

Verified
pip install selenium
export PYTHONWARNINGS="ignore:Unverified HTTPS request" //Disable ssl warning

Step 2: Set Your Credentials​


Configure your credentials to connect to the TestMu AI Selenium Grid.

Set TestMu AI Username and Access Key in environment variables.

Verified
export LT_USERNAME="undefined"
export LT_ACCESS_KEY="undefined"

Step 3: Configure Your Test Capabilities​


Define browser, version, and OS settings for your test run.

In the Python script, update your test capabilities. This code passes browser, browser version, and operating system information, along with TestMu AI Selenium grid capabilities via the capabilities object.

Verified
capabilities = {
"build": "your build name",
"name": "your test name",
"platformName": "Windows 10",
"browserName": "Chrome",
"browserVersion": "latest",
}
Capabilities Generator

Use the TestMu AI Capabilities Generator to auto-generate the capabilities class for your test requirements.

Step 4: Run the Test​


Execute the Python Selenium test from the command line.

The selenium-skill is part of TestMu AI Agent Skills - structured packages that teach AI coding assistants how to write production-grade test automation.

python google-search-lambdatest.py

Step 5: View Your Results​


Check the test output on the console and the TestMu AI dashboard.

Visit the TestMu AI Automation Dashboard to view your test results. The dashboard provides:

  • Text logs for each test step
  • Screenshots captured during execution
  • Video recordings of the full test session

Run Python Selenium Tests Using Agent Skills​


Use AI coding assistants to generate and run Python Selenium tests with the TestMu AI Agent Skill.

The selenium-skill is part of TestMu AI Agent Skills - structured packages that teach AI coding assistants how to write production-grade test automation.

Install the skill:

Verified
git clone https://github.com/LambdaTest/agent-skills.git
cp -r agent-skills/selenium-skill .claude/skills/

# For Cursor / Copilot
cp -r agent-skills/selenium-skill .cursor/skills/
tip

Install all available framework skills at once by cloning the repository directly into your tool's skills directory (e.g., .claude/skills/, .cursor/skills/).

Run a Test in Your Framework​


Each tab lists the framework-specific pieces. Clone the matching repo (it contains the full, ready-to-run project), then run.

The standard-library unittest framework connects a remote WebDriver to the grid, with capabilities inline in the test.

  1. Clone the sample GitHub project:
Verified
git clone https://github.com/LambdaTest/Python-UnitTest-Selenium
cd Python-UnitTest-Selenium
  1. Set your browser and OS in the capabilities dictionary:
Verified
capabilities = {
"build": "UnitTest-Selenium-Sample",
"name": "UnitTest-Selenium-Test",
"platformName": "Windows 11",
"browserName": "Chrome",
"browserVersion": "latest",
}
  1. Install the dependencies:
Verified
pip install -r requirements.txt
  1. Run the test:
Verified
python lambdatest_test.py

The test then appears on the Automation Dashboard. A green status confirms it passed.

View Your Results​


Your test results, including video, network logs, and command-by-command execution, appear on the TestMu AI Automation Dashboard.

Next steps: If this is your first run, walk through running your first Selenium test end to end. From there, explore the full set of Selenium automation capabilities you can pass to the grid, learn how to debug your Selenium tests, and organize and filter your Selenium tests as your suite grows.

Next Steps​


Continue with these related guides:

Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

×
Schedule Your Personal Demo
Kane CLI terminal

Help and Support

Related Articles