Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
# selenium
# Selenium Assignments

## 👥 Group No. 22

| Name | Enrollment No. | Section | Stream |
|---|---:|---|---|
| **Bibek Sow Mondal** | 12023002022112| B | CST |
| **Srishti Chatterjee** | 12023002022033| A | CST |
| **Bishal Dutta** | 12023002022115 | B | CST |

---
## 📌 About the Project

> **Team 22 — Selenium Automation Assignment**

This repository contains the **Selenium Automation Assignment** completed by **Team 22**.

This project focuses on web automation and software testing using Selenium with Python. It demonstrates how Selenium WebDriver can automate browser tasks on the Test Automation Practice website.

<br>

# Assignment Video Links

The following table contains the Google Drive links for the video demonstrations of the completed assignments.

| Assignment | Topic | Google Drive Video |
|---|---|---|
| **Assignment 1 and Assignment 2** | Web Element Identification and Multiple Element Identification | [▶️ Watch Video](https://drive.google.com/drive/u/0/folders/1Bkre0C0x5LwKf8o0rV_NdKODykSySIMa) |
| **Assignment 3** | CSS Selector Challenge | [▶️ Watch Video](https://drive.google.com/drive/u/0/folders/1Bkre0C0x5LwKf8o0rV_NdKODykSySIMa) |
| **Assignment 4** | Child Nodes Using CSS | [▶️ Watch Video](https://drive.google.com/drive/u/0/folders/1Bkre0C0x5LwKf8o0rV_NdKODykSySIMa) |


## Assignment Details

### 🔹 Assignment 1 — Web Element Identification

Identifying web elements using Selenium locators such as ID, Name, Tag Name, Link Text, and Class Name.

### 🔹 Assignment 2 — Multiple Element Identification

Locating multiple web elements using `find_elements()` and working with the returned list of elements.

### 🔹 Assignment 3 — CSS Selector Challenge

Locating web elements using CSS selectors and wildcard operators such as `^=`, `$=`, and `*=`.

### 🔹 Assignment 4 — Child Nodes Using CSS

Locating child and nested web elements using CSS child (`>`) and descendant selectors.

---

# 🛠️ Technologies Used

- Python
- Selenium WebDriver
- Google Chrome
- Browser Developer Tools
- Selenium Locators
- CSS Selectors

---

45 changes: 45 additions & 0 deletions Submissions/Assignment_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
""" Assignment 1 - Web Element Identification:
Identify and locate different web elements on a given webpage using
By.ID, By.NAME, By. TAG NAME, By. LINK TEXT, and By.CLASS NAME."""

from selenium import webdriver
from selenium.webdriver.common.by import By
import time

# Open the Chrome browser
driver = webdriver.Chrome()

# Open the website
driver.get("https://testautomationpractice.blogspot.com/")

#Maximize the browser window
driver.maximize_window()

time.sleep(5)


# By.ID
name = driver.find_element(By.ID, "name")
name.send_keys("Srishti")
print("1. Element located using ID")

# By.NAME
gender = driver.find_elements(By.NAME, "gender")
gender[1].click()
print("2. Female button selected using NAME")

# By.TAG_NAME
input_element = driver.find_element(By.TAG_NAME, "input")
print("3. Element located using TAG_NAME")

# By. LINK_TEXT
time.sleep(2)
apple = driver.find_element(By.LINK_TEXT, "Apple")
apple.click()
time.sleep(5)
print("4. Element located using LINK_TEXT")

# By. CLASS_NAME
element = driver.find_element(By.CLASS_NAME, "form-control")
element.send_keys("testing class")
time.sleep(5)
22 changes: 22 additions & 0 deletions Submissions/Assignment_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
""" Assignment 2 - Multiple Element Identification:
Identify multiple elements of the same type on a webpage and use Selenium to find and
work with the list of elements. """

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()

driver.get("https://testautomationpractice.blogspot.com/")
driver.maximize_window()

# Find all links on the webpage
links = driver.find_elements(By.TAG_NAME, "a")

print("Total number of links:", len(links))

# Print the text of each link
for link in links:
print(link.text)

driver.quit()
20 changes: 20 additions & 0 deletions Submissions/Assignment_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()

driver.get("https://testautomationpractice.blogspot.com/")
driver.maximize_window()

# Find elements whose ID starts with "name"
elements = driver.find_elements(
By.CSS_SELECTOR,
"[id^='name']"
)

print("Number of elements found:", len(elements))

for element in elements:
print("ID:", element.get_attribute("id"))

driver.quit()
25 changes: 25 additions & 0 deletions Submissions/Asssignment_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()

try:
driver.get("https://testautomationpractice.blogspot.com/")
driver.maximize_window()

time.sleep(5)

submit_button = driver.find_element(
By.CSS_SELECTOR,
"#section1 > button"
)

submit_button.click()

print("Submit button was located and clicked.")

time.sleep(5)

finally:
driver.quit()