Compare commits
2 Commits
5ebb0ccd6c
...
162b347119
Author | SHA1 | Date |
---|---|---|
mrlan | 162b347119 | |
ADMASU EDEN SOLOMON | da18cb617d |
|
@ -0,0 +1,46 @@
|
|||
Sign-Up Automation Test Script
|
||||
Overview
|
||||
This script automates the sign-up process for a web application using Selenium WebDriver. It tests whether form values are retained correctly if the initial sign-up attempt fails and requires modification of the student ID before resubmission.
|
||||
|
||||
Prerequisites
|
||||
Python 3
|
||||
Selenium library
|
||||
Chrome WebDriver
|
||||
A running instance of the web application on http://localhost:8080
|
||||
|
||||
Configuration
|
||||
Web Application URL: Make sure the web application is running at http://localhost:8080. Adjust the URL in the script if necessary.
|
||||
|
||||
Update Element Locators: Ensure the IDs used in the script (signup_link, signup_form, full_name, student_id, email, password1, password2, signup_btn) match those in your web application.
|
||||
|
||||
Run the script:
|
||||
|
||||
Script Logic
|
||||
|
||||
Open the Login Page: The script navigates to the login page of the web application.
|
||||
Click the "Sign Up" Link: It waits for the "Sign Up" link to appear and clicks it to navigate to the sign-up page.
|
||||
Fill Out the Sign-Up Form: It fills out the form fields (Full Name, Student ID, Email, Password).
|
||||
Submit the Form: It submits the form and waits for the result.
|
||||
Check for Sign-Up Failure: If sign-up fails, it checks if form values are retained.
|
||||
Modify Student ID: If the form values are retained, it modifies the student ID and resubmits the form.
|
||||
Verify Retained Values: It verifies if other fields retain their values after modifying the student ID.
|
||||
Print Retained Values: If the second attempt is successful, it prints the retained form values.
|
||||
Close the Browser: The browser is closed at the end of the script execution.
|
||||
|
||||
|
||||
|
||||
The script provides the following output:
|
||||
|
||||
Sign-Up Successful: Indicates the sign-up was successful on the first attempt.
|
||||
Sign-Up Failed: Indicates the sign-up failed on the first attempt and checks for retained values.
|
||||
Second Sign-Up Attempt Successful: Indicates the second sign-up attempt was successful and prints the retained values.
|
||||
Second Sign-Up Attempt Failed: Indicates the second sign-up attempt also failed, suggesting further investigation is needed.
|
||||
Notes
|
||||
Form Field IDs: Ensure the IDs used in the script match those in your web application.
|
||||
Password Fields: The script intentionally does not print password fields for security reasons.
|
||||
Adjust Wait Times: Modify the wait times as needed depending on your application's response times.
|
||||
Troubleshooting
|
||||
Element Not Found: Verify the element IDs and update them in the script.
|
||||
WebDriver Errors: Ensure the Chrome WebDriver is installed and matches your Chrome browser version.
|
||||
Connection Errors: Ensure the web application is running and accessible at the specified URL.
|
||||
Contributing
|
|
@ -0,0 +1,88 @@
|
|||
import time # Import time module for waiting
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
|
||||
# New instance of the Chrome driver
|
||||
driver = webdriver.Chrome()
|
||||
|
||||
try:
|
||||
# Step 1: Open the login page
|
||||
driver.get("http://localhost:8080/lrr/lrr/admin.php") # Replace with your actual login page URL
|
||||
|
||||
# Step 2: Wait for the login page to fully load and locate the "Sign Up" link
|
||||
sign_up_link = WebDriverWait(driver, 10).until(
|
||||
EC.presence_of_element_located((By.ID, "signup_link"))
|
||||
)
|
||||
|
||||
# Step 3: Click the "Sign Up" link to navigate to the sign-up page
|
||||
sign_up_link.click()
|
||||
|
||||
# Step 4: Wait for the sign-up page to fully load
|
||||
WebDriverWait(driver, 10).until(
|
||||
EC.presence_of_element_located((By.ID, "signup_form"))
|
||||
)
|
||||
|
||||
# Step 5: Fill out the sign-up form
|
||||
driver.find_element(By.ID, "full_name").send_keys("John Doe")
|
||||
driver.find_element(By.ID, "student_id").send_keys("12345678")
|
||||
driver.find_element(By.ID, "email").send_keys("john.doe@example.com")
|
||||
driver.find_element(By.ID, "password1").send_keys("Password123!")
|
||||
driver.find_element(By.ID, "password2").send_keys("Password123!")
|
||||
|
||||
# Step 6: Submit the sign-up form
|
||||
driver.find_element(By.ID, "signup_btn").click()
|
||||
|
||||
# Step 7: Wait for the sign-up result
|
||||
WebDriverWait(driver, 10).until(
|
||||
EC.presence_of_element_located((By.TAG_NAME, "body"))
|
||||
)
|
||||
|
||||
# Check if sign-up failed
|
||||
if "alert-danger" in driver.page_source:
|
||||
print("Sign-up failed. Checking if form values are retained...")
|
||||
|
||||
# Wait for a few seconds (adjust as needed)
|
||||
time.sleep(3)
|
||||
|
||||
# Modify the student ID again
|
||||
driver.find_element(By.ID, "student_id").clear()
|
||||
driver.find_element(By.ID, "student_id").send_keys("87654321")
|
||||
|
||||
# Verify if the other fields retain their values
|
||||
assert driver.find_element(By.ID, "full_name").get_attribute("value") == "John Doe"
|
||||
assert driver.find_element(By.ID, "email").get_attribute("value") == "john.doe@example.com"
|
||||
assert driver.find_element(By.ID, "password1").get_attribute("value") == ""
|
||||
assert driver.find_element(By.ID, "password2").get_attribute("value") == ""
|
||||
|
||||
# Resubmit the form
|
||||
driver.find_element(By.ID, "signup_btn").click()
|
||||
|
||||
# Wait for the result again
|
||||
WebDriverWait(driver, 10).until(
|
||||
EC.presence_of_element_located((By.TAG_NAME, "body"))
|
||||
)
|
||||
|
||||
# Check for success or failure after second attempt
|
||||
if "alert-danger" in driver.page_source:
|
||||
print("Second sign-up attempt failed. Further investigation needed.")
|
||||
|
||||
|
||||
# Print the retained values
|
||||
print("Retained form values after second attempt:")
|
||||
print("Full Name:", driver.find_element(By.ID, "full_name").get_attribute("value"))
|
||||
print("Email:", driver.find_element(By.ID, "email").get_attribute("value"))
|
||||
# Password fields might be intentionally cleared, so they won't be printed here
|
||||
print("Modified Student ID:", driver.find_element(By.ID, "student_id").get_attribute("value"))
|
||||
|
||||
else:
|
||||
print("Second sign-up attempt successful!")
|
||||
else:
|
||||
print("Sign-up successful!")
|
||||
|
||||
|
||||
|
||||
finally:
|
||||
# Close the browser
|
||||
driver.quit()
|
|
@ -0,0 +1,6 @@
|
|||
Sign-up failed. Checking if form values are retained...
|
||||
Second sign-up attempt failed. Further investigation needed.
|
||||
Retained form values after second attempt:
|
||||
Full Name: John Doe
|
||||
Email: john.doe@example.com
|
||||
Modified Student ID: 87654321
|
Loading…
Reference in New Issue