0% found this document useful (0 votes)
15 views8 pages

Sta Lab

The document outlines a series of 15 experiments using Selenium IDE and Python for web automation tasks, including launching a browser, printing webpage titles, checking number signs, and performing arithmetic operations. It also covers test cases for Gmail features, user registration and login, and book management functionalities. Each experiment includes code snippets demonstrating the implementation of the tasks described.

Uploaded by

navhans2104
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views8 pages

Sta Lab

The document outlines a series of 15 experiments using Selenium IDE and Python for web automation tasks, including launching a browser, printing webpage titles, checking number signs, and performing arithmetic operations. It also covers test cases for Gmail features, user registration and login, and book management functionalities. Each experiment includes code snippets demonstrating the implementation of the tasks described.

Uploaded by

navhans2104
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

List of Experiments

1. Install the free and open-source Selenium IDE as a Google Chrome extension, and
execute a basic script to automatically launch a web browser.

# Experiment 1: Launch a web browser using Selenium


from selenium import webdriver
# Initialize Chrome browser
driver = webdriver.Chrome()
# Open Google
driver.get("https://www.google.com")
# Wait and close
import time
time.sleep(3)
driver.quit()
2. Install the free and open-source Selenium IDE as a Google Chrome extension, and
execute a basic script to print the title of the web page opened in the browser.

# Experiment 2: Print the title of a webpage


from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com")
# Print the title
print("Title of the page:", driver.title)
driver.quit()
3. Install the free and open-source Selenium IDE as a Google Chrome extension, and
execute a basic script to print the chrome driver location as the output.

# Experiment 3: Print ChromeDriver version/location


from selenium import webdriver
driver = webdriver.Chrome()
version = driver.capabilities['chrome']['chromedriverVersion']
print("ChromeDriver Version:", version)
driver.quit()
4. Design test cases for checking the sign of given numbers and execute the same. Print
the status of the test cases along with the number of test cases run.

# Experiment 4: Check sign of a number


def check_sign(num):
if num > 0:
return "Positive"
elif num < 0:
return "Negative"
else:
return "Zero"
n = int(input("Enter the number to check sign: "))
print("Result:", check_sign(n))
print("Total Test Cases Run: 1")

5. Design test cases for checking the given number is odd or even and execute the same.
Print the status of the test cases along with the number of test cases run.

# Experiment 5: Check if number is odd or even


def check_odd_even(num):
return "Even" if num % 2 == 0 else "Odd"
n = int(input("Enter a number to check: "))
print(f"{n} is {check_odd_even(n)}")
print("Total Test Cases Run: 1")
6. Design test cases for the while loop implementation and print the status of the test
cases along with the number of test cases run.

# Experiment 6: While loop test case


def run_while(n):
result = []
while n > 0:
result.append(n)
n -= 1
return result
n = int(input("Enter a number for while loop: "))
print("While Loop Output:", run_while(n))
print("Test Case Passed")

7. Design test cases for the do while loop implementation and print the status of the test
cases along with the number of test cases run.

# Experiment 7: Simulate do-while loop


def do_while_sim(n):
result = []
while True:
result.append(n)
n -= 1
if n <= 0:
break
return result
n = int(input("Enter a number for do-while loop: "))
print("Do-While Loop Output:", do_while_sim(n))
print("Test Case Passed")

8. Install the free and open-source Selenium IDE as a Google Chrome extension. Design
and develop the test cases for compose feature in GMAIL and execute the same.
# Experiment 8: Compose mail in Gmail

from selenium import webdriver


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

driver = webdriver.Chrome()
driver.get("https://mail.google.com")

input("Please login to Gmail manually and press Enter to continue...")

try:
compose_btn = driver.find_element(By.XPATH, "//div[text()='Compose']")
compose_btn.click()
print("Compose button clicked successfully.")
except:
print("Could not find Compose button.")
time.sleep(3)
driver.quit()
9. Install the free and open-source Selenium IDE as a Google Chrome extension. Design
and develop the test cases for clicking “Delete” button in GMAIL and execute the same.
# Experiment 9: Click 'Delete' in Gmail

from selenium import webdriver


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

driver = webdriver.Chrome()
driver.get("https://mail.google.com")

input("Login to Gmail and select an email to delete. Press Enter to continue...")

try:
delete_button = driver.find_element(By.XPATH, "//div[@aria-label='Delete']")
delete_button.click()
print("Delete button clicked.")
except:
print("Delete button not found.")
time.sleep(3)
driver.quit()

10. Install the free and open-source Selenium IDE as a Google Chrome extension.
Design and develop the test cases for performing any two arithmetic operations in
calculator, and execute the same.
# Experiment 10: Perform arithmetic operation on Google calculator

from selenium import webdriver


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

driver = webdriver.Chrome()
driver.get("https://www.google.com/search?q=calculator")
time.sleep(2)

num1 = input("Enter first number: ")


op = input("Enter operator (+, -, *, /): ")
num2 = input("Enter second number: ")

driver.find_element(By.XPATH, f"//div[@aria-label='{num1}']").click()
driver.find_element(By.XPATH, f"//div[@aria-label='{op}']").click()
driver.find_element(By.XPATH, f"//div[@aria-label='{num2}']").click()
driver.find_element(By.XPATH, "//div[@aria-label='equals']").click()

print("Operation performed on Google Calculator.")


time.sleep(3)
driver.quit()
11. Install the free and open-source Selenium IDE as a Google Chrome extension.
Design and develop test cases for successful user registration, and execute the same.
# Experiment 11: User Registration form automation

from selenium import webdriver


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

driver = webdriver.Chrome()
driver.get("https://example.com/register") # Replace with real registration page

username = input("Enter a username: ")


password = input("Enter a password: ")

driver.find_element(By.ID, "username").send_keys(username)
driver.find_element(By.ID, "password").send_keys(password)
driver.find_element(By.ID, "register").click()

print("Registration form submitted.")


time.sleep(3)
driver.quit()

12. Install the free and open-source Selenium IDE as a Google Chrome extension.
Design and develop test cases for successful user login checking, and execute the same.
# Experiment 12: User Login form automation

from selenium import webdriver


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

driver = webdriver.Chrome()
driver.get("https://example.com/login") # Replace with actual login page

username = input("Enter your username: ")


password = input("Enter your password: ")

driver.find_element(By.ID, "username").send_keys(username)
driver.find_element(By.ID, "password").send_keys(password)
driver.find_element(By.ID, "login").click()

print("Login form submitted.")


time.sleep(3)
driver.quit()

13. Install the free and open-source Selenium IDE as a Google Chrome extension.
Design and develop test case for adding a new book, and execute the same.
# Experiment 13: Add a new book (example page)

from selenium import webdriver


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

driver = webdriver.Chrome()
driver.get("https://example.com/addbook") # Replace with actual URL

title = input("Enter book title: ")


author = input("Enter author name: ")

driver.find_element(By.ID, "title").send_keys(title)
driver.find_element(By.ID, "author").send_keys(author)
driver.find_element(By.ID, "submit").click()
print("Book added successfully.")
time.sleep(3)
driver.quit()

14. Install the free and open-source Selenium IDE as a Google Chrome extension.
Design and develop test case for searching a book, and execute the same.
# Experiment 14: Search a book (example site)

from selenium import webdriver


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

driver = webdriver.Chrome()
driver.get("https://example.com/searchbook") # Replace with actual URL

search_query = input("Enter book name to search: ")

driver.find_element(By.ID, "search").send_keys(search_query)
driver.find_element(By.ID, "submit").click()

print("Book search submitted.")


time.sleep(3)
driver.quit()

15. Install the free version of the software “Katalon Studio”. Design and develop test
cases for any simple program, and execute the same.

You might also like