diff --git a/README.md b/README.md index f6b37ae..947dd78 100644 --- a/README.md +++ b/README.md @@ -1 +1,63 @@ -# selenium \ No newline at end of file +# 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. + +
+ +# 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 + +--- + diff --git a/Submissions/Assignment_1.py b/Submissions/Assignment_1.py new file mode 100644 index 0000000..fa4cb4d --- /dev/null +++ b/Submissions/Assignment_1.py @@ -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) diff --git a/Submissions/Assignment_2.py b/Submissions/Assignment_2.py new file mode 100644 index 0000000..870285a --- /dev/null +++ b/Submissions/Assignment_2.py @@ -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() diff --git a/Submissions/Assignment_3.py b/Submissions/Assignment_3.py new file mode 100644 index 0000000..906c993 --- /dev/null +++ b/Submissions/Assignment_3.py @@ -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() diff --git a/Submissions/Asssignment_4.py b/Submissions/Asssignment_4.py new file mode 100644 index 0000000..740329c --- /dev/null +++ b/Submissions/Asssignment_4.py @@ -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()