From 8637258db443986f763029769ae2f7710bce56e1 Mon Sep 17 00:00:00 2001 From: Prateeksinha001 <> Date: Wed, 2 Sep 2026 08:29:48 +0530 Subject: [PATCH] Add submission for Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052 --- .../Assignment_1.3_Q1.py | 40 ++++++++++++++ .../Assignment_1.3_Q2.py | 22 ++++++++ .../Assignment_1.3_Q3.py | 29 ++++++++++ .../Assignment_1.3_Q4.py | 42 +++++++++++++++ .../README.md | 54 +++++++++++++++++++ 5 files changed, 187 insertions(+) create mode 100644 Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q1.py create mode 100644 Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q2.py create mode 100644 Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q3.py create mode 100644 Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q4.py create mode 100644 Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/README.md diff --git a/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q1.py b/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q1.py new file mode 100644 index 0000000..a03ecc8 --- /dev/null +++ b/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q1.py @@ -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() \ No newline at end of file diff --git a/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q2.py b/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q2.py new file mode 100644 index 0000000..dc456a7 --- /dev/null +++ b/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q2.py @@ -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() \ No newline at end of file diff --git a/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q3.py b/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q3.py new file mode 100644 index 0000000..8292813 --- /dev/null +++ b/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q3.py @@ -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() \ No newline at end of file diff --git a/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q4.py b/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q4.py new file mode 100644 index 0000000..39b197c --- /dev/null +++ b/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/Assignment_1.3_Q4.py @@ -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() \ No newline at end of file diff --git a/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/README.md b/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/README.md new file mode 100644 index 0000000..806014f --- /dev/null +++ b/Assignment_1.3/Abhinandan_Maity_12023052020050,Soufik_Aktar_12023052020049,Prateek_Sinha_12023052020007,Prasun_Sengupta_12023052019052/README.md @@ -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 \ No newline at end of file