0% found this document useful (0 votes)
20 views2 pages

Stqa P4

Uploaded by

dcruzsophia24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Stqa P4

Uploaded by

dcruzsophia24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PRACTICAL 4

AIM: Write a program using Selenium WebDriver to automate the login process on a specific
web page. Verify successful login with appropriate assertions

Step 1 Download Selenium Standalone Server

1. Download the Selenium Server: Visit the Selenium Downloads page and download the
Selenium Server (selenium-server-standalone.jar).

Step 2: Set Up Your Project in NetBeans

1. Open NetBeans: Start the NetBeans IDE.


2. Create a New Project:
o Go to File > New Project.
o Select Java under Categories and Java Application under Projects.
o Click Next.
o Name your project (e.g., STQA-P4) and choose a location for the project.
o Click Finish.

Step 3: Add Selenium JAR Files to Your Project

1. To add JAR Files to NetBeans: Right-click on your project in the Projects window and
select Properties.
2. Select Libraries from the categories on the left.
3. Click Add JAR/Folder.
4. Navigate to the directory where you downloaded the Selenium server jar file.
5. Add all the JAR files in the libs folder and the selenium-server-standalone.jar

Ms. Sophia Dcruz STQA-P2


Step 4: Write a Selenium Script

1. Create a New Java Class:


o Right-click on the Source Packages folder in the Projects window.
o Select New > Java Class.
o Name your class (e.g., Test4).
o Click Finish

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

/**
*
* @author Sophia
*/
public class STQA_P4 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver",
"C:/Users/Mathe/OneDrive/Desktop/chromedriver.exe");
WebDriver driver = new ChromeDriver();
ChromeOptions options = new ChromeOptions(); // URL of the login website that is
tested
driver.get("https://auth.geeksforgeeks.org/"); // Maximize window size of browser
driver.manage().window().maximize(); // Enter your login email id
driver.findElement(By.id("luser")).sendKeys("[email protected]"); // Enter
your login password
driver.findElement(By.id("password")).sendKeys("xyz12345");
driver.findElement(By.className("signin-button")).click();
System.out.println("Test executed successfully!");
driver.quit();
}

Step 5: Run the Test Suite

1. Select the test suite you created.


2. Click on the "Run" button to execute all the test cases in the suite.
3. Review the test results to ensure all test cases pass successfully.

Ms. Sophia Dcruz STQA-P2

You might also like