0% found this document useful (0 votes)
80 views

Selenium Testing

The document outlines the steps to set up Selenium testing for a Java project. It describes downloading and configuring Selenium, ChromeDriver, and JDK. It then provides examples of using Selenium to test a login page and stock page by automating interactions like entering credentials and values, clicking buttons, and validating page redirects. The examples demonstrate how to automate testing of a login and adding a book to stock.

Uploaded by

Aradina Babu
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

Selenium Testing

The document outlines the steps to set up Selenium testing for a Java project. It describes downloading and configuring Selenium, ChromeDriver, and JDK. It then provides examples of using Selenium to test a login page and stock page by automating interactions like entering credentials and values, clicking buttons, and validating page redirects. The examples demonstrate how to automate testing of a login and adding a book to stock.

Uploaded by

Aradina Babu
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

SELENIUM TESTING

SYSTEM SHOULD HAVE JDK


STEP 1 : INSTALL EXTENSION – EXTENSION PACK FOR
JAVA
STEP 2 : NEW WINDOW – CREATE JAVA PROJECT
STEP 3 : SELECT NO BUILD TOOLS
STEP 4 : DOWNLOAD SELENIUM

• https://www.selenium.dev/downloads/
STEP 5 : UNZIP THE FILE AND PASTE IT IN LIB FILE OF
YOUR PROJECT
STEP 6 : INSTALL CHROME DRIVER

• https://chromedriver.chromium.org/downloads
STEP 7 : EXTRACT WIN32.ZIP TO SRC – DRIVER(NEW
FOLDER)
LOGIN PAGE TESTING

import org.openqa.selenium.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class App {


    public static void main(String[] args) throws Exception {
        System.setProperty("webdriver.chrome.driver",
                "A:/Study/s9/seminar/mini/Testing/blounge/src/drivers/chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("http://127.0.0.1:8000/login");
        driver.findElement(By.id("uname")).sendKeys("[email protected]");
        driver.findElement(By.id("pass")).sendKeys("Riyan1@");
        driver.findElement(By.xpath("/html/body/div/form/input[4]")).click();
        String actualURL = "http://127.0.0.1:8000/memhome";
        String ExpectedURL = driver.getCurrentUrl();

        if (actualURL.equalsIgnoreCase(ExpectedURL)) {
            System.out.println("Test Passed");
        } else {
            System.out.println("Test Failed");
        }
    }
}
STOCK PAGE TESTING

import org.openqa.selenium.*;
driver.findElement(By.id("booktitle")).sendKeys("Safe
import org.openqa.selenium.WebDriver;
Haven");
import org.openqa.selenium.chrome.ChromeDriver;        
driver.findElement(By.id("type")).sendKeys("Hardcover");
public class app1 {        driver.findElement(By.id("price")).sendKeys("700");
    public static void main(String[] args) throws Exception {        driver.findElement(By.id("discount")).sendKeys("10");
        System.setProperty("webdriver.chrome.driver",         driver.findElement(By.id("qty")).sendKeys("4");
               
 driver.findElement(By.xpath("//*[@id='addbook']")).click();
"A:/Study/s9/seminar/mini/Testing/blounge/src/drivers/chromed         String actualURL = "http://127.0.0.1:8000/adbook";
river.exe");         String ExpectedURL = driver.getCurrentUrl();
        WebDriver driver = new ChromeDriver();
        if (actualURL.equalsIgnoreCase(ExpectedURL)) {
        driver.get("http://127.0.0.1:8000/login");
            System.out.println("Test Passed");
       
        } else {
driver.findElement(By.id("uname")).sendKeys("soorajsdas@gmail
.com");             System.out.println("Test Failed");
        }
       
driver.findElement(By.id("pass")).sendKeys("Soorajsd1@");     }
}
       
driver.findElement(By.xpath("/html/body/div/form/input[4]")).
click();
        driver.get("http://127.0.0.1:8000/adbook");
       

You might also like