Skip to main content

Quick Guide To Run Python Tests On LambdaTest Selenium Grid

LambdaTest Selenium Automation Grid is a cloud based scalable Selenium testing platform which enables you to run your automation scripts on 3000+ different browsers and operating systems. You can leverage LambdaTest Selenium grid to not only decrease the build time of Python automation scripts, but also increase your test coverage and check for more range of browsers for cross browser compatibility. This post will help you in getting started with configuring and running your Python based automation test scripts on LambdaTest Selenium cloud platform.


  • Make sure that you have the latest Python build installed. You can download the latest Python build from this page.

  • You would need Python package manager, pip, as well. Usually latest python installers come prepacked with pip. However, if you don’t have pip, you can install it using the below command:

      curl | python

Installing Selenium Dependencies For Python

Make sure that you have installed Selenium dependencies before executing your tests. You can use pip to install Selenium using following command:

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

Sample Python & Selenium Test To Get You started

Now we are all set to execute the first Python test on LambdaTest Selenium Grid. Checkout the sample code below. This is a simple python code that uses LambdaTest Selenium grid to open up Google. You can also download it from our GitHub repo.

Sample Python & Selenium Automation Script

LambdaTest Selenium automation sample example
username: Username can be found at automation dashboard
accessToken: AccessToken can be generated from automation dashboard or profile section

Execute Python Automation Tests on LambdaTest Distributed Selenium Grid
import unittest
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

class LTAutomate(unittest.TestCase):

Setup remote driver
platform : Supported platform - (Windows 10, Windows 8.1, Windows 8, Windows 7, macOS High Sierra, macOS Sierra, OS X El Capitan, OS X Yosemite, OS X Mavericks)
browserName : Supported platform - (chrome, firefox, Internet Explorer, MicrosoftEdge)
version : Supported list of version can be found at

def setUp(self):
# username: Username can be found at automation dashboard
# accessToken: AccessToken can be generated from automation dashboard or profile section
# gridUrl: gridUrl can be found at automation dashboard
gridUrl = ""

desired_cap = {
'platform' : "win10",
'browserName' : "chrome",
'version' : "67.0",
# Resolution of machine
"resolution": "1024x768",
"name": "LambdaTest python google search test ",
"build": "LambdaTest python google search build",
"network": True,
"video": True,
"visual": True,
"console": True,

# URL: https://{username}:{accessToken}
url = "https://"+username+":"+accessToken+"@"+gridUrl

print("Initiating remote driver on platform: "+desired_cap["platform"]+" browser: "+desired_cap["browserName"]+" version: "+desired_cap["version"])
self.driver = webdriver.Remote(
command_executor= url

Setup remote driver
Execute test: navigate search LambdaTest
print title
def test_search_in_google(self):
driver = self.driver
print("Driver initiated successfully. Navigate url")

print("Searching lambdatest on ")
elem = driver.find_element_by_name("q")

print("Printing title of current page :"+driver.title)
print("Requesting to mark test : pass")

Quit selenium driver
def tearDown(self):

if __name__ == "__main__":

You can execute the test from your terminal through this command.


The first thing to note here, is the use of remote WebDriver. Also checkout how the test passed on the enthronement configuration via desired_cap class.

To use your choice of environment for the test you can leverage our Capability Generator tool.

Tear Down: The tear down method helps LambdaTest platform understand when the execution of a test is finished. It’s important to tear down each test or else it will give timeout errors.