Power Your Software Testing 
 with AI and Cloud
Supercharge QA with AI for Faster & Smarter Software Testing

You can write and execute Selenium scripts with different programming languages and frameworks. However, for demonstration, we will take an example of Java programming. Besides, you must ensure the following things are configured on your machine.
Following are the steps to write and run test scripts in Selenium Java.
     org.Seleniumhq.Selenium
     Selenium-java
     3.141.59
     Test Scenario: The script launches the LambdaTest login page (https://accounts.lambdatest.com/login), enters a valid name and password, clicks on the Login button and verifies the page’s title to ensure the user logged in successfully and then routed to the LambdaTest home page.
Shown below is the test script for the above test scenario.
Package MyTests;
 
 import org.openqa.Selenium.By;
 import org.openqa.Selenium.WebDriver;
 import org.openqa.Selenium.WebElement;
 import org.openqa.Selenium.chrome.ChromeDriver;
 import org.testng.Assert;
  
 import java.util.concurrent.TimeUnit;
  
 public class SimpleTest {
     public static void main(String[] args) {
  
         System.setProperty("webdriver.chrome.driver",
         "C:\Users\Shalini\Downloads
         \chromedriver_win\chromedriver.exe");
         WebDriver driver = new ChromeDriver();
  
         String url = "https://accounts.lambdatest.com/login";
  
         driver.get(url);
         driver.manage().window().maximize();
         driver.manage().timeouts().pageLoadTimeout
         (10, TimeUnit.SECONDS);
  
  
         WebElement email = driver.findElement(By.id("email"));
         WebElement password = driver.findElement(By.id("password"));
         WebElement loginButton = driver.findElement
         (By.id("login-button"));
  
         email.clear();
         email.sendKeys("abc@gmail.com");
  
         password.clear();
         password.sendKeys("abc@123");
  
         loginButton.click();
  
         String title = "Welcome - LambdaTest";
  
         String actualTitle = driver.getTitle();
  
         Assert.assertEquals(actualTitle,title,
            "Page title doesnt match");
  
  
 System.out.println("User logged in successfully");
  
        
 driver.quit();
     }
 }
  
  To implement the above Login scenario, you need to

Once tests are executed, you can see the results in the IDE console.

KaneAI - Testing Assistant
World’s first AI-Native E2E testing agent.

Get 100 minutes of automation test minutes FREE!!