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
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()

driver.get("https://the-internet.herokuapp.com/login")

driver.maximize_window()

# 1. Locate using ID
username = driver.find_element(By.ID, "username")
print("Username field:", username.get_attribute("id"))

# 2. Locate using NAME
password = driver.find_element(By.NAME, "password")
print("Password field:", password.get_attribute("name"))

# 3. Locate using TAG_NAME
heading = driver.find_element(By.TAG_NAME, "h2")
print("Heading:", heading.text)

# 4. Locate using LINK_TEXT
logout_link = driver.find_element(By.LINK_TEXT, "Elemental Selenium")
print("Link:", logout_link.text)

# 5. Locate using CLASS_NAME
login_button = driver.find_element(By.CLASS_NAME, "radius")
print("Button:", login_button.text)

# Enter values
username.send_keys("tomsmith")
password.send_keys("SuperSecretPassword!")

# Click Login
login_button.click()

time.sleep(2)

driver.quit()
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()

driver.get("https://the-internet.herokuapp.com/")

driver.maximize_window()

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

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

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

time.sleep(2)

driver.quit()
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()

driver.get("https://the-internet.herokuapp.com/challenging_dom")

driver.maximize_window()

# CSS selector - locate buttons
buttons = driver.find_elements(By.CSS_SELECTOR, "a.button")

print("Number of buttons:", len(buttons))

for button in buttons:
print("Button text:", button.text)

# CSS selector - locate table rows
rows = driver.find_elements(By.CSS_SELECTOR, "table tbody tr")

print("\nNumber of rows:", len(rows))

for row in rows:
print(row.text)

time.sleep(2)

driver.quit()
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()

driver.get("https://the-internet.herokuapp.com/add_remove_elements/")

driver.maximize_window()

# Parent div
parent = driver.find_element(By.CSS_SELECTOR, "div.example")

print("Parent found:", parent.tag_name)

# Child button inside the parent
add_button = parent.find_element(
By.CSS_SELECTOR,
"button"
)

print("Button text:", add_button.text)

# Click Add Element
add_button.click()

time.sleep(1)

# Locate Delete button
delete_button = parent.find_element(
By.CSS_SELECTOR,
"button.added-manually"
)

print("Delete button:", delete_button.text)

# Click Delete
delete_button.click()

time.sleep(2)

driver.quit()
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Selenium Assignments_1.3

## Students

**Name:** Abhinandan Maity
**Enrollment Number:** 12023052020050

**Name:** Soufik Aktar
**Enrollment Number:** 12023052020049

**Name:** Prateek Sinha
**Enrollment Number:** 12023052020007

**Name:** Prasun Sengupta
**Enrollment Number:** 12023052019052

## Description

This submission contains our Selenium assignments:

- Assignment 1: Web Element Identification
- Assignment 2: Multiple Element Identification
- Assignment 3: CSS Selector Challenge
- Assignment 4: Child Nodes Using CSS

All assignments were implemented using Python and Selenium WebDriver.

## Assignments

### Assignment 1
Used Selenium locators:
- ID
- Name
- Tag Name
- Link Text
- Class Name

### Assignment 2
Used `find_elements()` to locate multiple elements and print their text.

### Assignment 3
Used CSS selectors including:
- ID selector
- Attribute selector
- Wildcard selectors

### Assignment 4
Used CSS child selectors to locate nested web elements.

## Demo

https://drive.google.com/file/d/199ZIY6ljlAEE5xphwNc-IDGkiI-zaRpb/view?usp=drivesdk

https://drive.google.com/file/d/10KQha-H6ktEckLtNcjmBmIlu13ONdw1E/view?usp=drivesdk