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

Selenium

Uploaded by

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

Selenium

Uploaded by

scrpionff332005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

School: ............................................................................................................. Campus: .......................................................

Academic Year: ...................... Subject Name: ........................................................... Subject Code: ..........................

Semester: ............... Program: ........................................ Branch: ......................... Specialization: ..........................

Date: .....................................

(Learning by Doing and Discovery)

* Coding Phase: Pseudo Code / Flow Chart / Algorithm


Selenium is a popular open-source framework for automating web applications for testing purposes.
In Java, Selenium allows you to interact with web elements, automate tasks, and perform end-to-end
tests on web applications.

Objective
The objective of this lab is to understand and implement web automation testing using Selenium
WebDriver in Java. We aim to automate a simple search scenario on Google to demonstrate the core
functionalities of Selenium.

Steps to Configure Java Environment


Step 1: Firstly, configure the Java Development Kit on your system. If not configured, then refer to the
following installation steps here.

Step 2: Ensure that Java has been successfully installed on your system by running the command

Step 3: Now, install an Integrated Development Environment (IDE) such as Eclipse, IntelliJ IDEA,
or NetBeans. For this, we are using Eclipse so download it from here.

Step 4: Install the Selenium WebDriver library for Java. Download it from here. Extract the Zip File
and complete the installation.

Step 5: We need web browsers such as Chrome, Firefox, Edge, or Safari. So, for this article
demonstration, we will use the Chrome browser. A ChromeDriver executable file that matches your
Chrome version. Download the latest release from here.

Step 6: Extract the zip file and copy the path where the chromedriver.exe file is, it is required in
further steps. (e.g. – D:/chromedriver_win32/chromedriver.exe)

One sheet per experiment (10-20) to be used.


Create a Selenium with Java Project in Eclipse

Step 1: Launch Eclipse and select File -> New -> Java Project.

Step 2: Enter a name for your project (e.g., SeleniumJavaTutorial) and click Finish.

One sheet per experiment (10-20) to be used.


Step 3: Right-click on your project in Package Explorer and select Properties.

Step 4: Select Java Build Path from the left panel click on the libraries tab and then select Classpath.
Click on Add External JARs and browse to the location where you downloaded the Selenium WebDriver
library (e.g., selenium-java-4.1.0.zip).

Step 5: Select all the JAR files inside the zip file and click Open and also all the files inside the lib
folder. (D:\selenium-java-4.11.0, D:\selenium-java-4.11.0\lib).

One sheet per experiment (10-20) to be used.


Step 7: Create a new package under your project by right-clicking on the src folder and selecting New
-> Package.

Step 8: Add the name of your package (e.g., WebDriver)

Step 9: Create a new class under your package (e.g., WebDriver) by right-clicking on the package
and selecting New -> Class, then Enter a name for your class and click Finish.

One sheet per experiment (10-20) to be used.


Testing Phase: Compilation of Code

Step 1: Import the required packages at the top of your class:


import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
After importing if still getting errors in import just delete the module-info.java file.
Step 2: Create a main class inside the Web class.
public class Web {
public static void main(String[] args) {
}
}
Step 3: Set the system property for ChromeDriver (path to chromedriver executable). (e.g.,
D:/chromedriver_win32/chromedriver.exe)
System.setProperty(“webdriver.chrome.driver”, “D:/chromedriver_win32/chromedriver.exe”);
Step 4: Create an instance of ChromeDriver.
WebDriver driver = new ChromeDriver();
Step 5: Navigate to the desired website.
driver.get(“https://www.geeksforgeeks.org/”);
Step 6: Get and print the page title.
String pageTitle = driver.getTitle();
System.out.println(“Page Title: ” + pageTitle);
Step 7: Wait for a few seconds.
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Step 8: Close the browser.
driver. Quit();

*As applicable according to the experiment.


One sheet per experiment (10-20) to be used.
Applied and Action Learning

* Implementation Phase: Final Output (no error)

Rubrics
Concept 10
Planning and Execution/ 10
Practical Simulation/ Programming
Result and Interpretation 10
Record of Applied and Action Learning 10
Viva 10
Total 50

Signature of the Student:

Signature of the Faculty:


*As applicable according to the experiment.
One sheet per experiment (10-20) to be used.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy