Practical 7
Practical Title:
To understand automated testing concepts and Selenium architecture for web
applications
Theory:
1. What is Automated Testing?
Automated testing is a technique where test cases are executed using tools/scripts instead
of manual effort.
It helps in faster and more accurate testing of applications.
__________________________________________________________
2. What is Selenium?
Selenium is an open-source tool used for automating web browsers.
It is widely used for testing web applications.
__________________________________________________________
3. Selenium Components:
Selenium IDE: Record and playback tool (beginner-friendly)
Selenium WebDriver: Automates browser actions using code (most powerful)
Selenium Grid: Runs tests on multiple machines/browsers simultaneously
__________________________________________________________
4. Selenium Architecture:
Selenium works in this flow:
Test Script → WebDriver → Browser → Application
Test script sends commands
WebDriver communicates with browser
Browser performs actions on web application
__________________________________________________________
Procedure:
Step 1: Install Selenium and required dependencies
Step 2: Setup WebDriver
Step 3: Write a simple test script
Step 4: Perform actions (click, input, etc.)
Step 5: Execute the test script
Activity / Task:
Task 1:
Write a Selenium script to open a website and perform basic actions.
Code:
package [Link];
import [Link];
import [Link];
import [Link];
public class TestSelenium {
public static void main(String[] args) throws InterruptedException
{
WebDriver driver = new ChromeDriver();
[Link]("[Link]
[Link](2000);
[Link]([Link]("q")).sendKeys("Selenium DevOps
Test");
[Link](3000);
[Link]();
}
}
__________________________________________
Task 2:
List advantages of automated testing over manual testing.
• Faster execution
• More accurate
• Reusable scripts
• Saves time and effort
• Supports continuous testing
__________________________________________
Advantages:
1. Reduces human error
2. Speeds up testing
3. Improves test coverage
4. Supports CI/CD
5. Efficient for repetitive tasks
Challenges:
1. Requires coding knowledge
2. Maintenance of test scripts
3. Initial setup time