LambdaTest Running Your First Test on LambdaTest Estimated reading: 2 minutes 46 views Running Your First Test on LambdaTest is a critical step towards efficient, reliable, and scalable web application testing. In my experience as a QA tester, utilizing cloud platforms like LambdaTest significantly streamlines the testing process, allowing you to quickly validate your application across multiple browsers and devices simultaneously. In this guide, I will walk you through how to adapt an existing Selenium TestNG test to run seamlessly on LambdaTest, using the Kicks Web App as an example.Setting Up LambdaTest EnvironmentTo begin running your test on LambdaTest, you first need to configure your WebDriver to connect to the LambdaTest platform. Unlike local tests, running tests on LambdaTest requires you to use their remote WebDriver URL and authentication credentials.First, you need to import essential libraries and define your setup within your test class:LambdaTest WebDriver Setuppackage com.kicksapp.test; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.openqa.selenium.*; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.testng.Assert; import java.net.URL; import java.time.Duration; private WebDriver driver; private String testUrl = "https://jahmalrichard.github.io/kicks-flutter-web-app/"; @BeforeMethod public void setUp() throws Exception { String username = System.getenv("LT_USERNAME") == null ? "jahmalrichardpro" : System.getenv("LT_USERNAME"); String authkey = System.getenv("LT_ACCESS_KEY") == null ? "iHE17Brcqb7zxbkcwJ9bcqR9ByHuFe0irHEmKlITmCdaGBktnn" : System.getenv("LT_ACCESS_KEY"); String hub = "@hub.lambdatest.com/wd/hub"; ChromeOptions browserOptions = new ChromeOptions(); HashMap<String, Object> ltOptions = new HashMap<String, Object>(); ltOptions.put("username", username); ltOptions.put("accessKey", authkey); ltOptions.put("visual", true); ltOptions.put("video", true); ltOptions.put("build", "MQA Kicks App Demo"); ltOptions.put("project", "Selenium Kicks App Test"); ltOptions.put("name", "Kicks App - Add To Cart"); String[] customTags = {"Selenium", "TestNG", "Automation"}; ltOptions.put("tags", customTags); ltOptions.put("console", "true"); ltOptions.put("selenium_version", "4.0.0"); ltOptions.put("w3c", true); browserOptions.setCapability("LT:Options", ltOptions); driver = new RemoteWebDriver(new URL("https://" + username + ":" + authkey + hub), browserOptions); driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20)); driver.manage().window().maximize(); }Replace YOUR_LAMBDATEST_USERNAME and YOUR_LAMBDATEST_ACCESS_KEY with your LambdaTest account credentials, which you can find in your LambdaTest dashboard under the Automation tab.Executing the Test on LambdaTestWith the setup complete, let’s implement the test method:KicksApp – Add Shoe To Cart Test@Test public void addShoeToCartAndShippingInfoTest() throws InterruptedException { driver.get(testUrl); driver.findElement(By.cssSelector("flt-semantics[aria-label=\"Products\"]")).click(); driver.findElement(By.cssSelector("flt-semantics[aria-label=\"Most popular\"]")).click(); WebElement selectConverseShoe = driver.findElement(By.cssSelector("flt-semantics[aria-label*=\"Adidas Converse\"]")); selectConverseShoe.click(); Thread.sleep(3000); WebElement selectSizeText = driver.findElement(By.cssSelector("flt-semantics[aria-label=\"Select size\"]")); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", selectSizeText); Thread.sleep(2000); driver.findElement(By.cssSelector("flt-semantics[aria-label=\"10\"]")).click(); Thread.sleep(2000); driver.findElement(By.cssSelector("flt-semantics[aria-label=\"Add to cart\"]")).click(); Thread.sleep(2000); WebElement cartTab = driver.findElement(By.cssSelector("flt-semantics[aria-label*=\"cart-icon\"]")); Assert.assertTrue(cartTab.isDisplayed(), "One item is currently in the cart!"); cartTab.click(); Thread.sleep(2000); WebElement proceedToCheckoutButton = driver.findElement(By.cssSelector("flt-semantics[aria-label=\"Proceed to Checkout\"]")); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", proceedToCheckoutButton); proceedToCheckoutButton.click(); driver.findElement(By.cssSelector("input[aria-label=\"Email\"]")).sendKeys("johnsmith@test.com"); driver.findElement(By.cssSelector("input[aria-label=\"Name\"]")).sendKeys("John"); driver.findElement(By.cssSelector("input[aria-label=\"Last Name\"]")).sendKeys("Smith"); driver.findElement(By.cssSelector("input[aria-label=\"Address\"]")).sendKeys("123 Test Ave"); driver.findElement(By.cssSelector("input[aria-label=\"Apt, Unit\"]")).sendKeys("A"); driver.findElement(By.cssSelector("input[aria-label*=\"Town\"]")).sendKeys("Quality Town"); driver.findElement(By.cssSelector("input[aria-label=\"Country\"]")).sendKeys("United States"); driver.findElement(By.cssSelector("input[aria-label=\"ZIP\"]")).sendKeys("12345"); driver.findElement(By.cssSelector("input[aria-label=\"State\"]")).sendKeys("NY"); Thread.sleep(3000); WebElement proceedToDeliveryButton = driver.findElement(By.cssSelector("flt-semantics[aria-label=\"Proceed to Delivery\"]")); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", proceedToDeliveryButton); proceedToDeliveryButton.click(); Thread.sleep(2000); } @AfterMethod public void tearDown() { if (driver != null) { driver.quit(); } }The above test validates essential user interactions like adding a product to the cart and entering checkout information. Observing Test ResultsOnce you run your test, you can observe detailed logs, screenshots, and video recordings on the LambdaTest dashboard. This makes debugging much easier and gives clear visibility into your test execution outcomes.ConclusionRunning Your First Test on LambdaTest can significantly enhance your testing efficiency, allowing you to easily validate your web applications across multiple platforms and browsers. By following these simple steps and adapting your local tests for cloud execution, you streamline your QA process effectively. In the next guide we’ll dive into Understanding LambdaTest Capabilities and Configurations. LambdaTest - Previous Setting Up LambdaTest for Automated Testing Next - LambdaTest Protected: Understanding LambdaTest Capabilities and Configurations