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
19 changes: 19 additions & 0 deletions Assignment_1.3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Assignment 1.3

Name: Sayan Dey
Enrollment Number:- 12023052016061

## Description

Web element identification and Selenium locator practice.

## Files

- `main.py` - Assignment 1 & 2
- `test2.py` - Assignmen 3
- `test3.py` - Assignment 4

## Demo

Demo video links will be added here.
https://drive.google.com/drive/folders/1s3P5M70LLcIpDMJr_hO0hrsPcsu_q496?usp=sharing
28 changes: 28 additions & 0 deletions Assignment_1.3/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Firefox()

try:
driver.get("https://testautomationpractice.blogspot.com/")
#BY ID
phone = driver.find_element(By.ID, "phone")
print("By ID: ", phone.get_attribute("placeholder"))
# BY NAME
gender = driver.find_element(By.NAME, "gender")
print("By Name: ", gender.get_attribute("value"))
# By TAG
links = driver.find_elements(By.TAG_NAME, "a")
print("By TAG_NAME: Number of Links -> ", len(links))

for link in links:
print('Link: ', link.text)
#BY LINK_TEXT
apple = driver.find_element(By.LINK_TEXT, "Apple")
print("By LINK_TEXT: ", apple.text)
#BY CLASS_NAME
visitor = driver.find_element(By.CLASS_NAME, "counter-wrapper")
print("By.CLASS_NAME: ", visitor.get_attribute('textContent'))

finally:
driver.quit()
38 changes: 38 additions & 0 deletions Assignment_1.3/test2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Firefox()

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

# CSS selector using ID
name = driver.find_element(By.CSS_SELECTOR, "#name")
print("ID selector:", name.get_attribute("placeholder"))

# CSS selector using class
counter = driver.find_element(By.CSS_SELECTOR, ".counter-wrapper")
print("Class selector:", counter.get_attribute("textContent"))

#CSS attribute selector
phone = driver.find_element(
By.CSS_SELECTOR,
'input[placeholder="Enter Phone"]'
)
print("Attribute selector:", phone.get_attribute("id"))

stats = driver.find_element(
By.CSS_SELECTOR, '[id^="Stats1_"]'
)
print("Starts with (^=):", stats.get_attribute("id"))
stats_contains = driver.find_element(By.CSS_SELECTOR,'[id*="Stats1"]'
)
print("Contains (*=):", stats_contains.get_attribute("id"))

total = driver.find_element(
By.CSS_SELECTOR, '[id$="totalCount"]'
)
print("Ends with ($=):", total.get_attribute("id"))

finally:
driver.quit()
17 changes: 17 additions & 0 deletions Assignment_1.3/test3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Firefox()

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

button = driver.find_element(
By.CSS_SELECTOR,
"div.dropdown > button"
)

print("Button:", button.text)

finally:
driver.quit()