LambdaTest Selenium Automation Grid enables you to perform end-to-end automation tests on a secure, reliable, and scalable Selenium infrastructure. You can perform automated cross browser testing with Selenium scripts on 2000+ browsers and operating systems environments, giving you higher test coverage and at significantly less built times. LambdaTest will help you evaluate how well your web application renders when accessed through a variety of different browsers. You can perform automated cross-browser testing of your locally hosted web pages using Lambda Tunnel. You could also run a single test across multiple browser/OS configurations simultaneously. This post will help you to quickly get started with running your automation test scripts on LambdaTest Selenium automation grid.
To see the complete list of Supported Languages and Frameworks, please refer here.
We are preparing documentation for more frameworks. If you want us to prioritize documentation of your beloved framework then feel free to give us a shout.
LambdaTest recommends you to always use the latest version of the Selenium WebDriver for your particular scripting language.
LambdaTest Capabilities Generator will by default make use of latest compatible Selenium version based on the selections of browser/OS configurations. However, you are also allowed to test across other Selenium versions, in case if you want to run your automation script through a specific, legacy Selenium version. Below is the representation of the default Selenium versions used depending upon your browser selection.
Note:‘selenium_version’ is the desire capability responsible for selecting a Selenium version at LambdaTest. For instance,
1 |
'selenium_version' = '3.13.0' |
To run your Selenium tests on the LambdaTest requires a username and an access key. You can always get your username and access key from the Desired Capabilities Generator, as shown in the below image:
When you start with automation testing for the first time, we understand it might not be that easy to run your project in the first go (it might be due to an environment problem, project setup, or something else). But don’t worry! We got you covered.
We will help you get started with automation testing on LambdaTest in a flash speed. This document will provide a step by step guide to get started and run your first automation test. Let’s get you started.
When you open the Automation dashboard for the first time, you can see the two options to get started with automation testing on LambdaTest:
Let’s see both of these features one by one.
If you want to run the automation tests on cloud-based workspace Gitpod, instead of your local machine, with the help of LambdaTest’s cloud-based online Selenium grid, you can choose the option Run in Gitpod.
You can choose among the available list of languages and frameworks available, to view the test script and execute it on Gitpod.
Currently, we provide demos for the following languages and frameworks, but we support all. You can view the complete list from here.
Let’s see each of the above frameworks one by one.
When you choose PyTest framework under Python language in the dialog box that appears, you will be redirected to the cloud based online workspace on Gitpod.
Once you log in, you can see the sample PyTest repo being loaded in the Gitpod workspace.
In this Gitpod workspace, your username and the access key will be automatically embedded. But you can always get your username and access key from the Desired Capabilities Generator, as shown in the below image:
By default, this repo runs the test on the below desired capabilities:
1 2 3 4 5 6 7 8 9 |
desired_caps = { "build": 'PyunitTest sample build', # Change your build name here "name": 'Py-unittest', # Change your test name here "platform": 'OS X El Capitan', # Change your OS version here "browserName": 'chrome', # Change your browser here "version": '81.0', # Change your browser version here "console": 'true', # Enable or disable console logs "network":'true' # Enable or disable network logs } |
To run the tests on a different environment than above, you can use the Desired Capabilities Generator to select the desired capabilities and copy paste the code in the single_test.py file, on line 13-18.
The test scenario in this repo includes:
Below is the complete code for the above test script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import os import unittest import sys from selenium import webdriver username = os.environ.get("LT_USERNAME") access_key = os.environ.get("LT_ACCESS_KEY") class FirstSampleTest(unittest.TestCase): # Generate capabilites from here: https://www.lambdatest.com/capabilities-generator/ # setUp runs before each test case and def setUp(self): desired_caps = { "build": 'PyunitTest sample build', # Change your build name here "name": 'Py-unittest', # Change your test name here "platform": 'OS X El Capitan', # Change your OS version here "browserName": 'chrome', # Change your browser here "version": '81.0', # Change your browser version here "console": 'true', # Enable or disable console logs "network":'true' # Enable or disable network logs } self.driver = webdriver.Remote( command_executor="https://{}:{}@hub.lambdatest.com/wd/hub".format(username, access_key), desired_capabilities= desired_caps) # tearDown runs after each test case def tearDown(self): self.driver.quit() # """ You can write the test cases here """ def test_unit_user_should_able_to_add_item(self): # try: driver = self.driver # Url driver.get("https://lambdatest.github.io/sample-todo-app/") # Click on check box check_box_one = driver.find_element_by_name("li1") check_box_one.click() # Click on check box check_box_two = driver.find_element_by_name("li2") check_box_two.click() # Enter item in textfield textfield = driver.find_element_by_id("sampletodotext") textfield.send_keys("Yey, Let's add it to list") # Click on add button add_button = driver.find_element_by_id("addbutton") add_button.click() # Verified added item added_item = driver.find_element_by_xpath("//span[@class='done-false']").text print (added_item) if __name__ == "__main__": unittest.main() |
To run the Single Test using Python PyTest framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 |
python single_test.py |
As soon as you press Enter, the test execution will start. You can switch back to the automation dashboard to see the test being queued and running, after you reload the page. The tests will be executed, and you can see the status of the tests.
To know more about how to access and manage your automation dashboard, you can refer to this document.
To run the Parallel Test using the Python PyTest framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 |
python parallel_test.py |
To know more about running tests in PyTest framework on LambdaTest, please refer here.
To know more about running tests in other Python frameworks on LambdaTest, please refer here.
When you choose Robot framework under Python language in the dialog box that appears, you will be redirected to the cloud based online workspace on Gitpod.
Once you log in, you can see the sample Robot repo being loaded in the Gitpod workspace.
In this Gitpod workspace, your username and the access key will be automatically embedded. But you can always get your username and access key from the Desired Capabilities Generator, as shown in the below image:
By default, this repo runs the test on the user-specified desired capabilities, passed using the code:
1 2 3 4 5 6 7 8 9 10 |
*** Variables *** @{_tmp} ... browserName: ${browserName}, ... platform: ${platform}, ... version: ${version}, ... visual: ${visual}, ... network: ${network}, ... console: ${console}, ... name: RobotFramework Lambda Test |
The test scenario in this repo includes:
Below is the complete code for the above test script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
*** Settings *** Resource ../Resources/Common.robot Test Setup Common.Open test browser Test Teardown Common.Close test browser *** Variables *** *** Test Cases *** Example of connecting to Lambdatest via Robot Framework [Timeout] ${TIMEOUT} Page should contain element name:li1 Page should contain element name:li2 Click button name:li1 Click button name:li2 Input text id:sampletodotext Yey Let's add it to list Click button id:addbutton ${response} Get Text xpath=/html/body/div/div/div/ul/li[6]/span Should Be Equal As Strings ${response} Yey Let's add it to list |
To run the Single Test using Python Robot framework, just copy the below code and paste it in the console of the Gitpod workspace. This code passes the desired capabilities as Windows 10, Chrome and 68 for the capabilities platform, browser name and browser version respectively.
1 |
make test_Windows_10_chrome_68 |
As soon as you press Enter, the test execution will start. You can switch back to the automation dashboard to see the test being queued and running, after you reload the page. The tests will be executed, and you can see the status of the tests.
To know more about how to access and manage your automation dashboard, you can refer to this document.
To run the Parallel Test using the Python PyTest framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 |
make run_all_in_parallel |
To know more about running tests in Robot framework on LambdaTest, please refer here.
To know more about running tests in other Python frameworks on LambdaTest, please refer here.
When you choose JUnit framework under Java language in the dialog box that appears, you will be redirected to the cloud based online workspace on Gitpod.
Once you log in, you can see the sample JUnit repo being loaded in the Gitpod workspace.
In this Gitpod workspace, your username and the access key will be automatically embedded. But you can always get your username and access key from the Desired Capabilities Generator, as shown in the below image:
By default, this repo runs the test on the below desired capabilities:
1 2 3 4 5 6 7 8 9 10 11 12 |
DesiredCapabilities capability = new DesiredCapabilities(); capability.setCapability(CapabilityType.BROWSER_NAME, browser); capability.setCapability(CapabilityType.VERSION, version); capability.setCapability(CapabilityType.PLATFORM, os); capability.setCapability("build", "Junit Single Test"); capability.setCapability("name", "JUnit Single"); capability.setCapability("screen_resolution", res); capability.setCapability("network", true); capability.setCapability("video", true); capability.setCapability("console", true); capability.setCapability("visual", "true"); |
To run the tests on a different environment than above, you can use the Desired Capabilities Generator to select the desired capabilities and copy paste the code in the SingleTest.java file, on line 33-43.
The test scenario in this repo includes:
Below is the complete code for the above test script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
package com.lambdatest.Tests; import java.net.URL; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; public class SingleTest { public static WebDriver driver; public static String status = "failed"; @Before public void setUp() throws Exception { String browser = Configuration.readConfig("browser"); String version = Configuration.readConfig("version"); String os = Configuration.readConfig("os"); String res = Configuration.readConfig("resolution"); String username = System.getenv("LT_USERNAME") != null ? System.getenv("LT_USERNAME") : Configuration.readConfig("LambdaTest_UserName"); String accesskey = System.getenv("LT_ACCESS_KEY") != null ? System.getenv("LT_ACCESS_KEY") : Configuration.readConfig("LambdaTest_AppKey"); DesiredCapabilities capability = new DesiredCapabilities(); capability.setCapability(CapabilityType.BROWSER_NAME, browser); capability.setCapability(CapabilityType.VERSION, version); capability.setCapability(CapabilityType.PLATFORM, os); capability.setCapability("build", "Junit Single Test"); capability.setCapability("name", "JUnit Single"); capability.setCapability("screen_resolution", res); capability.setCapability("network", true); capability.setCapability("video", true); capability.setCapability("console", true); capability.setCapability("visual", "true"); String gridURL = "https://" + username + ":" + accesskey + "@hub.lambdatest.com/wd/hub"; driver = new RemoteWebDriver(new URL(gridURL), capability); } @Test public void test() { // Launch the app driver.get("https://lambdatest.github.io/sample-todo-app/"); // Click on First Item driver.findElement(By.name("li1")).click(); // Click on Second Item driver.findElement(By.name("li2")).click(); // Add new item is list driver.findElement(By.id("sampletodotext")).clear(); driver.findElement(By.id("sampletodotext")).sendKeys("Yey, Let's add it to list"); driver.findElement(By.id("addbutton")).click(); // Verify Added item String item = driver.findElement(By.xpath("/html/body/div/div/div/ul/li[6]/span")).getText(); Assert.assertTrue(item.contains("Yey, Let's add it to list")); status = "passed"; } @After public void afterTest() { ((JavascriptExecutor) driver).executeScript("lambda-status=" + status + ""); driver.quit(); } } |
To run the Single Test using Java JUnit framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 |
mvn test -P single |
As soon as you press Enter, the test execution will start. You can switch back to the automation dashboard to see the test being queued and running, after you reload the page. The tests will be executed and you can see the status of the tests.
To know more about how to access and manage your automation dashboard, you can refer to this document.
To know more about running tests in JUnit framework on LambdaTest, please refer here.
To know more about running tests in other Java frameworks on LambdaTest, please refer here.
When you choose TestNG framework under Java language in the dialog box that appears, you will be redirected to the cloud based online workspace on Gitpod.
Once you log in, you can see the sample TestNG repo being loaded in the Gitpod workspace.
In this Gitpod workspace, your username and the access key will be automatically embedded. But you can always get your username and access key from the Desired Capabilities Generator, as shown in the below image:
By default, this repo runs the test on the below desired capabilities:
1 2 3 4 5 6 7 8 9 10 11 |
DesiredCapabilities capability = new DesiredCapabilities(); capability.setCapability(CapabilityType.BROWSER_NAME, browser); capability.setCapability(CapabilityType.VERSION, version); capability.setCapability(CapabilityType.PLATFORM, platform); capability.setCapability("build", "TestNG Single Test"); capability.setCapability("name", "TestNG Single"); capability.setCapability("network", true); capability.setCapability("video", true); capability.setCapability("console", true); capability.setCapability("visual", true); |
To run the tests on a different environment than above, you can use the Desired Capabilities Generator to select the desired capabilities and copy paste the code in the SingleTest.java file, on line 30-39.
The test scenario in this repo includes:
Below is the complete code for the above test script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
package com.lambdatest.Tests; import org.testng.annotations.Test; import org.testng.AssertJUnit; import java.net.URL; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Parameters; public class SingleTest { //Lambdatest Credentails can be found here at https://www.lambdatest.com/capabilities-generator String username = System.getenv("LT_USERNAME") == null ? "YOUR LT_USERNAME" : System.getenv("LT_USERNAME"); String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "YOUR LT_ACCESS_KEY" : System.getenv("LT_ACCESS_KEY"); public static WebDriver driver; public static String status = "failed"; @BeforeTest(alwaysRun=true) @Parameters(value = { "browser", "version", "platform" }) public void setUp(String browser, String version, String platform) throws Exception { DesiredCapabilities capability = new DesiredCapabilities(); capability.setCapability(CapabilityType.BROWSER_NAME, browser); capability.setCapability(CapabilityType.VERSION, version); capability.setCapability(CapabilityType.PLATFORM, platform); capability.setCapability("build", "TestNG Single Test"); capability.setCapability("name", "TestNG Single"); capability.setCapability("network", true); capability.setCapability("video", true); capability.setCapability("console", true); capability.setCapability("visual", true); String gridURL = "http://" + username + ":" + accessKey + "@hub.lambdatest.com/wd/hub"; try { driver = new RemoteWebDriver(new URL(gridURL), capability); } catch (Exception e) { System.out.println("driver error"); System.out.println(e.getMessage()); } } @Test public static void test() { try { // Launch the app driver.get("https://lambdatest.github.io/sample-todo-app/"); // Click on First Item driver.findElement(By.name("li1")).click(); // Click on Second Item driver.findElement(By.name("li2")).click(); // Add new item is list driver.findElement(By.id("sampletodotext")).clear(); driver.findElement(By.id("sampletodotext")).sendKeys("Yey, Let's add it to list"); driver.findElement(By.id("addbutton")).click(); // Verify Added item String item = driver.findElement(By.xpath("/html/body/div/div/div/ul/li[6]/span")).getText(); AssertJUnit.assertTrue(item.contains("Yey, Let's add it to list")); status = "passed"; ((JavascriptExecutor) driver).executeScript("lambda-status=" + status + ""); } catch (Exception e) { System.out.println(e.getMessage()); } catch (Error e) { System.out.println("Assert failed"); } } @AfterTest public static void afterTest() { ((JavascriptExecutor) driver).executeScript("lambda-status=" + status + ""); driver.quit(); } } |
To run the Single Test using Java TestNG framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 |
mvn test -P single |
As soon as you press Enter, the test execution will start. You can switch back to the automation dashboard to see the test being queued and running, after you reload the page. The tests will be executed and you can see the status of the tests.
To know more about how to access and manage your automation dashboard, you can refer to this document.
To run the Parallel Test using the Java TestNG framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 |
mvn test -P parallel |
To know more about running tests in TestNG framework on LambdaTest, please refer here.
To know more about running tests in other Java frameworks on LambdaTest, please refer here.
When you choose Cucumber framework under Java language in the dialog box that appears, you will be redirected to the cloud based online workspace on Gitpod.
Once you log in, you can see the sample Cucumber repo being loaded in the Gitpod workspace.
In this Gitpod workspace, your username and the access key will be automatically embedded. But you can always get your username and access key from the Desired Capabilities Generator, as shown in the below image:
By default, this repo runs the test on the below desired capabilities:
1 2 3 4 5 6 7 8 9 10 11 |
DesiredCapabilities capability = new DesiredCapabilities(); capability.setCapability(CapabilityType.BROWSER_NAME, browser); capability.setCapability(CapabilityType.VERSION, version); capability.setCapability(CapabilityType.PLATFORM, platform); capability.setCapability("build", "Cucumber-Selenium-TestNG Test"); capability.setCapability("name", "Cucumber-Selenium Test"); capability.setCapability("network", true); capability.setCapability("video", true); capability.setCapability("console", true); capability.setCapability("visual", true); |
To run the tests on a different environment than above, you can use the Desired Capabilities Generator to select the desired capabilities and copy paste the code in the ToDoStepDefinition.java file, on line 34-44.
The test scenario in this repo includes:
Below is the complete code for the above test script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
package stepDefinitions; import java.net.URL; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.testng.Assert; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; public class ToDoStepDefinition { WebDriver driver; public static String status = "failed"; @Given("^user is on home Page$") public void user_already_on_home_page() throws Exception { String browser = Configuration.readConfig("browser"); String version = Configuration.readConfig("version"); String os = Configuration.readConfig("os"); String res = Configuration.readConfig("resolution"); String username = System.getenv("LT_USERNAME") != null ? System.getenv("LT_USERNAME") : Configuration.readConfig("LambdaTest_UserName"); String accesskey = System.getenv("LT_ACCESS_KEY") != null ? System.getenv("LT_ACCESS_KEY") : Configuration.readConfig("LambdaTest_AppKey"); DesiredCapabilities capability = new DesiredCapabilities(); capability.setCapability(CapabilityType.BROWSER_NAME, browser); capability.setCapability(CapabilityType.VERSION, version); capability.setCapability(CapabilityType.PLATFORM, os); capability.setCapability("screen_resolution", res); capability.setCapability("build", "Cucumber-Selenium-TestNG Test"); capability.setCapability("name", "Cucumber-Selenium-TestNG"); capability.setCapability("network", true); capability.setCapability("video", true); capability.setCapability("console", true); capability.setCapability("visual", true); String gridURL = "https://" + username + ":" + accesskey + "@hub.lambdatest.com/wd/hub"; driver = new RemoteWebDriver(new URL(gridURL), capability); driver.get("https://lambdatest.github.io/sample-todo-app/"); } @When("^select First Item$") public void select_first_item() { driver.findElement(By.name("li1")).click(); } @Then("^select second item$") public void select_second_item() { driver.findElement(By.name("li2")).click(); } @Then("^add new item$") public void add_new_item() { driver.findElement(By.id("sampletodotext")).clear(); driver.findElement(By.id("sampletodotext")).sendKeys("Yey, Let's add it to list"); driver.findElement(By.id("addbutton")).click(); } @Then("^verify added item$") public void verify_added_item() { String item = driver.findElement(By.xpath("/html/body/div/div/div/ul/li[6]/span")).getText(); Assert.assertTrue(item.contains("Yey, Let's add it to list")); status = "passed"; } @Then("^Update the result$") public void update_result() { ((JavascriptExecutor) driver).executeScript("lambda-status=" + status + ""); } @Then("^Close the browser$") public void close_the_browser() { driver.quit(); } } |
To run the Single Test using Java Cucumber framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 |
mvn test |
As soon as you press Enter, the test execution will start. You can switch back to the automation dashboard to see the test being queued and running, after you reload the page. The tests will be executed and you can see the status of the tests.
To know more about how to access and manage your automation dashboard, you can refer to this document.
To know more about running tests in Cucumber framework on LambdaTest, please refer here.
To know more about running tests in other Java frameworks on LambdaTest, please refer here.
When you choose NightwatchJS framework under Javascript language in the dialog box that appears, you will be redirected to the cloud based online workspace on Gitpod.
Once you log in, you can see the sample NightwatchJS repo being loaded in the Gitpod workspace.
In this Gitpod workspace, your username and the access key will be automatically embedded. But you can always get your username and access key from the Desired Capabilities Generator, as shown in the below image:
The test scenario in this repo includes:
Below is the complete code for the above test script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
var https = require("https"); var lambdaRestClient = require("@lambdatest/node-rest-client"); var lambdaCredentials = { username: process.env.LT_USERNAME, accessKey: process.env.LT_ACCESS_KEY }; var lambdaAutomationClient = lambdaRestClient.AutomationClient( lambdaCredentials ); module.exports = { "@tags": ["test"], Google: function(client) { client .url("https://www.google.com/ncr") .waitForElementVisible("body", 10000) .setValue("input[type=text]", "LambdaTest\n") .pause(1000) .assert.title("LambdaTest - Google Search") .end(); }, after: function(browser) { console.log("Closing down..."); }, afterEach: function(client, done) { if ( process.env.LT_USERNAME && process.env.LT_ACCESS_KEY && client.capabilities && client.capabilities["webdriver.remote.sessionid"] ) { lambdaAutomationClient.updateSessionById( client.capabilities["webdriver.remote.sessionid"], { status_ind: client.currentTest.results.failed ? "failed" : "passed" }, function(error, session) { console.log(error) if (!error) { client.pause(10000) done(); } } ); } else { client.pause(10000) done(); } } }; |
To run the Single Test using Javascript NightwatchJS framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 2 3 4 5 |
<em>Linux/Mac</em> $ ./node_modules/.bin/nightwatch -e chrome tests <em>Windows</em> $ node_modules\.bin\nightwatch -e chrome tests |
As soon as you press Enter, the test execution will start. You can switch back to the automation dashboard to see the test being queued and running, after you reload the page. The tests will be executed and you can see the status of the tests.
To know more about how to access and manage your automation dashboard, you can refer to this document.
To know more about running tests in NightwatchJS framework on LambdaTest, please refer here.
To know more about running tests in other Javascript frameworks on LambdaTest, please refer here.
When you choose WebDriverIO framework under Javascript language in the dialog box that appears, you will be redirected to the cloud based online workspace on Gitpod.
Once you log in, you can see the sample WebDriverIO repo being loaded in the Gitpod workspace.
In this Gitpod workspace, your username and the access key will be automatically embedded. But you can always get your username and access key from the Desired Capabilities Generator, as shown in the below image:
The test scenario in this repo includes:
Below is the complete code for the above test script:
1 2 3 4 5 6 7 8 9 10 11 12 |
const assert = require('assert'); describe('Google Search Function', () => { it('can find search results', () => { browser.url('https://www.google.com/ncr'); const input = $('[name="q"]'); input.setValue('test123'); const title = browser.getTitle(); assert.equal(title, 'Google'); }); }); |
To run the Single Test using Javascript WebDriverIO framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 |
npm run single |
As soon as you press Enter, the test execution will start. You can switch back to the automation dashboard to see the test being queued and running, after you reload the page. The tests will be executed and you can see the status of the tests.
To know more about how to access and manage your automation dashboard, you can refer to this document.
To run the Parallel Test using the Javascript WebDriverIO framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 |
npm run parallel |
To know more about running tests in WebDriverIO framework on LambdaTest, please refer here.
To know more about running tests in other Javascript frameworks on LambdaTest, please refer here.
When you choose TestCafe framework under Javascript language in the dialog box that appears, you will be redirected to the cloud based online workspace on Gitpod.
Once you log in, you can see the sample TestCafe repo being loaded in the Gitpod workspace.
In this Gitpod workspace, your username and the access key will be automatically embedded. But you can always get your username and access key from the Desired Capabilities Generator, as shown in the below image:
By default, this repo runs the test on the default desired capabilities. To run the tests on a different environment than above, you can use the Desired Capabilities Generator to select the desired capabilities.
To run the Single Test using Javascript TestCafe framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 |
testcafe "lambdatest:Chrome@74.0:Windows 8" 'path/to/test/file.js' |
As soon as you press Enter, the test execution will start. You can switch back to the automation dashboard to see the test being queued and running, after you reload the page. The tests will be executed, and you can see the status of the tests.
To know more about how to access and manage your automation dashboard, you can refer to this document.
To run the Parallel Test using the Javascript TestCafe framework, just copy the below code and paste it in the console of the Gitpod workspace:
1 |
testcafe "lambdatest:Chrome@74.0:Windows 8","lambdatest:Chrome@75.0:Windows 10" "path/to/test/file.js" |
To know more about running tests in TestCafe framework on LambdaTest, please refer here.
To know more about running tests in other Javascript frameworks on LambdaTest, please refer here.
If you want to run the automation tests on your local machine, with the help of LambdaTest’s cloud-based online Selenium grid, you can choose the option Get Started.
Once you do, you can see the option to run tests on various languages like:
You can select the language of your choice to get started. For demo purpose, we will show you how to get started with each language.
If you choose Java as your preferred language to get started, you will see a window like below, where you can configure your test script and environment based on your choice.
So to run your Java test on local machine:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
@Test(enabled = true) public void testScript() throws Exception { try { driver.get("https://lambdatest.github.io/sample-todo-app/"); driver.findElement(By.name("li1")).click(); driver.findElement(By.name("li2")).click(); driver.findElement(By.id("sampletodotext")).clear(); driver.findElement(By.id("sampletodotext")).sendKeys("Yey, Let's add it to list"); driver.findElement(By.id("addbutton")).click(); driver.quit(); } catch (Exception e) { System.out.println(e.getMessage()); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
//This is maven project package lambdatest; //<your package name> import org.testng.annotations.Test; import java.net.MalformedURLException; import java.net.URL; import org.openqa.selenium.By; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.testng.annotations.BeforeTest; public class Lambdatest { public RemoteWebDriver driver = null; String username = "rishabhps"; String accessKey = "euSJFdOOh4ItQlkv7ihsOne0E03OrbGIe1uux1pVLcZHP7NNof"; @BeforeTest public void setUp() throws Exception { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("platform", "Windows 10"); capabilities.setCapability("browserName", "Chrome"); capabilities.setCapability("version", "88.0"); // If this cap isn't specified, it will just get the any available one capabilities.setCapability("resolution", "1024x768"); capabilities.setCapability("build", "First Test"); capabilities.setCapability("name", "Sample Test"); capabilities.setCapability("network", true); // To enable network logs capabilities.setCapability("visual", true); // To enable step by step screenshot capabilities.setCapability("video", true); // To enable video recording capabilities.setCapability("console", true); // To capture console logs try { driver = new RemoteWebDriver(new URL("https://" + username + ":" + accessKey + "@stage-hub.lambdatest.com/wd/hub"), capabilities); } catch (MalformedURLException e) { System.out.println("Invalid grid URL"); } } @Test(enabled = true) public void testScript() throws Exception { try { driver.get("https://lambdatest.github.io/sample-todo-app/"); driver.findElement(By.name("li1")).click(); driver.findElement(By.name("li2")).click(); driver.findElement(By.id("sampletodotext")).clear(); driver.findElement(By.id("sampletodotext")).sendKeys("Yey, Let's add it to list"); driver.findElement(By.id("addbutton")).click(); driver.quit(); } catch (Exception e) { System.out.println(e.getMessage()); } } } |
1 |
cd /path/to/the/test/directory |
Then you need to run the test from maven via surefire plugin, using the below command:
1 |
mvn test |
That’s all. This will run your tests and you can see the output in your console.
Note: If you decide at anytime that you don’t want to run your test locally, or want to try out the cloud-based workspace to execute the test, just click on the “Run in Gitpod” option available on your screen.
Similarly, if you choose Node JS as your preferred language to get started, the steps will remain the same as above Java language, except the internal code and syntax details. You will see a window like below to configure your test script and environment based on your choice.
So to run your Node JS test on the local machine:
1 2 3 4 5 6 7 8 9 10 |
// navigate to a url, search for a text and get title of page driver.get('https://www.google.com/ncr').then(function() { driver.findElement(webdriver.By.name('q')).sendKeys('LambdaTest').then(function() { driver.getTitle().then(function(title) { setTimeout(function() { console.log(title); driver.quit(); }, 5000); }); }); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
const webdriver = require('selenium-webdriver'); // username: Username can be found at automation dashboard const USERNAME = 'rishabhps'; // Accesskey: Accesskey can be generated from automation dashboard or profile section const KEY = 'euSJFdOOh4ItQlkv7ihsOne0E03OrbGIe1uux1pVLcZHP7NNof'; // gridUrl: gridUrl can be found at automation dashboard const GRID_HOST = 'stage-hub.lambdatest.com/wd/hub'; function searchTextOnGoogle() { // Setup Input capabilities const capabilities = { platform: 'Windows 10', browserName: 'Chrome', version: '88.0', resolution: '1024x768', network: true, visual: true, console: true, video: true, name: 'Test 1', // name of the test build: 'NodeJS build' // name of the build } // URL: https://{username}:{accessKey}@hub.lambdatest.com/wd/hub const gridUrl = 'https://' + USERNAME + ':' + KEY + '@' + GRID_HOST; // setup and build selenium driver object const driver = new webdriver.Builder() .usingServer(gridUrl) .withCapabilities(capabilities) .build(); // navigate to a url, search for a text and get title of page driver.get('https://www.google.com/ncr').then(function() { driver.findElement(webdriver.By.name('q')).sendKeys('LambdaTest ').then(function() { driver.getTitle().then(function(title) { setTimeout(function() { console.log(title); driver.quit(); }, 5000); }); }); }); } searchTextOnGoogle(); |
1 |
cd /path/to/the/test/directory |
You would also need the latest Selenium client and its WebDriver Bindings. Selenium can be downloaded using the code given below. You should always run the latest version of Selenium Client and WebDriver on LambdaTest Selenium cloud grid to avoid any errors.
1 |
npm i selenium-webdriver |
1 |
node lambdatest.js |
That’s all. This will run your tests and you can see the output in your console.
Note: If you decide at anytime that you don’t want to run your test locally, or want to try out the cloud-based workspace to execute the test, just click on the “Run in Gitpod” option available on your screen.
Similarly, if you choose Python as your preferred language to get started, the steps will remain the same as above Java language, except the internal code and syntax details. You will see a window like below to configure your test script and environment based on your choice.
So to run your Python test on the local machine:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
def test_unit_user_should_able_to_add_item(self): # try: driver = self.driver # Url driver.get("https://lambdatest.github.io/sample-todo-app/") # Click on check box check_box_one = driver.find_element_by_name("li1") check_box_one.click() # Click on check box check_box_two = driver.find_element_by_name("li2") check_box_two.click() # Enter item in textfield textfield = driver.find_element_by_id("sampletodotext") textfield.send_keys("Yey, Let's add it to list") # Click on add button add_button = driver.find_element_by_id("addbutton") add_button.click() # Verified added item added_item = driver.find_element_by_xpath("//span[@class='done-false']").text print (added_item) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import unittest import sys from selenium import webdriver username = "rishabhps" # Replace the username access_key = "euSJFdOOh4ItQlkv7ihsOne0E03OrbGIe1uux1pVLcZHP7NNof" # Replace the access key class FirstSampleTest(unittest.TestCase): # Generate capabilites from here: https://www.lambdatest.com/capabilities-generator/ # setUp runs before each test case and def setUp(self): desired_caps = { "build": 'PyunitTest sample build', # Change your build name here "name": 'Py-unittest', # Change your test name here "platform": 'Windows 10', # Change your OS version here "browserName": 'Chrome', # Change your browser here "version": '88.0', # Change your browser version here "resolution": '1024x768', # Change your resolution here "console": 'true', # Enable or disable console logs "network":'true' # Enable or disable network logs } self.driver = webdriver.Remote( command_executor="https://{}:{}@stage-hub.lambdatest.com/wd/hub".format(username, access_key), desired_capabilities= desired_caps) # tearDown runs after each test case def tearDown(self): self.driver.quit() # """ You can write the test cases here """ def test_unit_user_should_able_to_add_item(self): # try: driver = self.driver # Url driver.get("https://lambdatest.github.io/sample-todo-app/") # Click on check box check_box_one = driver.find_element_by_name("li1") check_box_one.click() # Click on check box check_box_two = driver.find_element_by_name("li2") check_box_two.click() # Enter item in textfield textfield = driver.find_element_by_id("sampletodotext") textfield.send_keys("Yey, Let's add it to list") # Click on add button add_button = driver.find_element_by_id("addbutton") add_button.click() # Verified added item added_item = driver.find_element_by_xpath("//span[@class='done-false']").text print (added_item) if __name__ == "__main__": unittest.main() |
1 |
cd /path/to/the/test/directory |
You would also need the latest Selenium client and its WebDriver Bindings. Selenium can be downloaded using the code given below. You should always run the latest version of Selenium Client and WebDriver on LambdaTest Selenium cloud grid to avoid any errors.
1 |
pip install pytest && pip install selenium>2.5 |
1 |
python lambdatest.py |
That’s all. This will run your tests and you can see the output in your console.
Note: If you decide at anytime that you don’t want to run your test locally, or want to try out the cloud-based workspace to execute the test, just click on the “Run in Gitpod” option available on your screen.
Similarly, if you choose Ruby as your preferred language to get started, the steps will remain the same as above Java language, except the internal code and syntax details. You will see a window like below to configure your test script and environment based on your choice.
So to run your Ruby test on the local machine:
1 2 3 4 5 6 7 |
driver.navigate.to "https://lambdatest.github.io/sample-todo-app/" driver.find_element(:name, 'li1') driver.find_element(:name, 'li2') driver.find_element(:id, 'sampletodotext').send_keys("Yey, Let's add it to list") driver.find_element(:id, 'addbutton').click enteredText = driver.find_element(:xpath, '/html/body/div/div/div/ul/li[6]/span').text status = true if enteredText == "Yey, Let's add it to list" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
require 'rubygems' require 'selenium-webdriver' # Input capabilities USERNAME = 'rishabhps' ACCESS_KEY = 'euSJFdOOh4ItQlkv7ihsOne0E03OrbGIe1uux1pVLcZHP7NNof' caps = Selenium::WebDriver::Remote::Capabilities.new caps[:browserName] = 'Chrome' caps[:platform] = 'Windows 10' caps[:version] = '88.0' caps[:resolution] = '1024x768' caps[:name] = 'LT sample Test' # test name caps[:build] = 'LT sample build' # CI/CD job or build name driver = Selenium::WebDriver.for(:remote, :url => "https://#{USERNAME}:#{ACCESS_KEY}@stage-hub.lambdatest.com/wd/hub", :desired_capabilities => caps) driver.navigate.to "https://lambdatest.github.io/sample-todo-app/" driver.find_element(:name, 'li1') driver.find_element(:name, 'li2') driver.find_element(:id, 'sampletodotext').send_keys("Yey, Let's add it to list") driver.find_element(:id, 'addbutton').click enteredText = driver.find_element(:xpath, '/html/body/div/div/div/ul/li[6]/span').text status = true if enteredText == "Yey, Let's add it to list" driver.quit |
1 |
cd /path/to/the/test/directory |
You would also need the latest Selenium client and its WebDriver Bindings. Selenium can be downloaded using the code given below. You should always run the latest version of Selenium Client and WebDriver on LambdaTest Selenium cloud grid to avoid any errors.
1 |
gem install selenium-webdriver && gem install ffi |
1 |
ruby lambdatest.rb |
That’s all. This will run your tests, and you can see the output in your console.
LambdaTest supports the following Continuous Integration tools:
LambdaTest integrates with the project management applications. With the help of these integrations you can directly send the tracked bug in LambdaTest in a single-click to these applications.
List of project management tools which can be integrated with the LambdaTest.
If your tool is not in the list, let LambdaTest Support team know about it.