How To Automate Login Page Using Selenium WebDriver?

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • NodeJs-Cucumber-Selenium

    Run test automation on cloud with Cucumber.js and LambdaTest. This is a sample repo to help you execute Cucumber.js framework based test scripts in parallel with LambdaTest automation testing cloud

  • import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Parameters; import org.testng.annotations.Test; import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit; public class LoginTest { public String username = "YOUR_USERNAME"; public String accesskey = "YOUR_ACCESSKEY"; public static RemoteWebDriver driver = null; public String gridURL = "@hub.lambdatest.com/wd/hub"; @BeforeClass @Parameters("browser") public void setUp(String browser) throws Exception { DesiredCapabilities capabilities = new DesiredCapabilities(); if (browser.equalsIgnoreCase("Chrome")) { capabilities.setCapability("browserName", "chrome"); capabilities.setCapability("version", "93.0"); capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one capabilities.setCapability("build", "LoginTest"); capabilities.setCapability("name", "LoginTestInChrome"); } else if (browser.equalsIgnoreCase("Firefox")) { capabilities.setCapability("browserName", "Firefox"); //To specify the browser capabilities.setCapability("version", "76.0"); //To specify the browser version capabilities.setCapability("platform", "win10"); // To specify the OS capabilities.setCapability("build", "LoginTest"); //To identify the test capabilities.setCapability("name", "LoginTestInFirefox"); } try { driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities); } catch (MalformedURLException e) { System.out.println("Invalid grid URL"); } catch (Exception e) { System.out.println(e.getMessage()); } } @Test() public void test_1() { String url = "https://www.lambdatest.com/"; driver.get(url); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); WebElement login = driver.findElement(By.linkText("Login")); System.out.println("Clicking on the login element in the main page"); login.click(); 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(); System.out.println("Entering the email"); email.sendKeys("your_email”); password.clear(); System.out.println("entering the password"); password.sendKeys("your_password"); System.out.println("Clicking login button"); loginButton.click(); String title = "Welcome - LambdaTest"; String actualTitle = driver.getTitle(); System.out.println("Verifying the page title has started"); Assert.assertEquals(actualTitle,title,"Page title doesnt match"); System.out.println("The page title has been successfully verified"); System.out.println("User logged in successfully"); } @AfterClass public void closeBrowser() { driver.close(); } }

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts