Selenium Testing
Selenium Testing
• 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;
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");