Software Testing Manual
Software Testing Manual
Step 2:
• Install Selenium WebDriver.
• To install Selenium WebDriver use this command : pip install selenium.
Step 3:
• https://googlechromelabs.github.io/chrome-for-testing/#stable click on this link and
open it in chrome browser.
• Search for the below given zip file and click on that to download.
Step 4:
• Now go to the File Explorer →Downloads→open the downloaded zip file. In that
open the zip file as it shows like this→ .In that copy the file named
as chromedriver.exe.
• In the next step go to C-Drive and create a new folder (Ex:tools).
• In that created new folder create one more folder named as chromedriver.
• Paste the file we have copied in the newly created folder as chromedriver.
• After this copy the path something look like this: (C:\tools\chromedriver).
• Now open “Edit the system environment variables” after opening this in bottom
we can see the button as “Environment Variables” .In both user variables and
syatem variables we can see the path section open and add the path copied in both
part.
• Then click on “OK” to add the path.
Step 5:
• Then go back to the command prompt verify that the chromedriver has installed
properly using the command as: chromedriver –version
Step 6:
• Open the Visual studio code.
• Create a new window and open new terminal.
• In terminal check whether Selenium and Chromedriver installed correctly or not.
• To check that type as chromedriver --version.
Step 7:
• Create a new folder in C-Drive and name it as “selenium”.
• Open selenium folder in VS-Code (Visual studio code).
• Create a new file name the file with .py extension (Ex:admin.py).
Type this code:
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
driver.get("https://www.google.com")
print("Title:", driver.title)
driver.quit()
In terminal to run the code type as: python admin.py.
Output:
Step 8:
• Once again open command prompt.
• Type as: pip install selenium==2.53.1
• Now click on this link provided below:
https://selenium-release.storage.googleapis.com/index.html
• Then click on 2.53→ search for this selenium-server-standalone-2.53.1.jar.
• Open selenium folder that we have already created in C-Drive copy the jar file that
look something like this→ into the selenium folder .
Step 9:
• Go to VS-Code create an another file (Ex:index.py).
Type this code:
import time
# Initialize WebDriver
driver = webdriver.Chrome()
driver.get("https://opensource-demo.orangehrmlive.com/web/index.php/auth/login")
driver.find_element(By.NAME, "username").send_keys("Admin")
# Step 3: Enter Password
driver.find_element(By.NAME, "password").send_keys("admin123")
driver.find_element(By.XPATH, "//button[@type='submit']").click()
time.sleep(5)
if "dashboard" in driver.current_url:
print("Login Test Passed")
else:
# Close browser
driver.quit()
Output: To run the code use this in terminal python log.py
Once the code is executed, the URL provided in the code opens directly in chrome and
automatically takes username and password , then you will be logged in.
Step 2:
• Create a another file in the same folder.
• Name the file (Ex: csvfile.py).
Type this code:
wb = Workbook()
ws = wb.active
# Add headers
wb.save("testdata.xlsx")
print("Excel file 'testdata.xlsx' created successfully!")
Step 3:
• Create a another file in the same folder.
• Name the file (Ex: final.py).
Type this code:
import pandas as pd
from selenium import webdriver
df = pd.read_excel("testdata.xlsx")
# Initialize WebDriver
driver = webdriver.Chrome()
try:
# Open OrangeHRM login page
driver.get("https://opensource-demo.orangehrmlive.com/web/index.php/auth/login")
username_field = wait.until(EC.presence_of_element_located((By.XPATH,
"//input[@name='username']")))
password_field = wait.until(EC.presence_of_element_located((By.XPATH,
"//input[@name='password']")))
login_button = wait.until(EC.element_to_be_clickable((By.XPATH,
"//button[@type='submit']")))
username_field.send_keys(str(row["Username"]))
password_field.send_keys(str(row["Password"]))
login_button.click()
# Wait for URL to change indicating login attempt
current_url = driver.current_url
else:
except TimeoutException:
if row["Expected Result"].strip().lower() == "fail":
else:
driver.quit()
After completing execution you will see the invalid credentials message in the website.
Program 8 - Using Selenium IDE: Develop a test suite containing
minimum 4 test cases.
Step 1:
• Open chrome browser , search for Selenium IDE for FireFox.
• Click on Download FireFox and get the extension button an FireFox installer.exe
will be downloaded.
• Click on FireFox installer.exe file. Now the extension will be downloaded.
Step 2:
• Open FireFox extensions.
Step 3:
• Open SeleniumIDE.
• Click on Create a new project.
• Name the project (Ex: lab8_info).
• Click on ok.
Step 4:
• https://the-internet.herokuapp.com/login
Password : SuperSecretePassword!.
Step 5:
• Once the recording is completed click on stop recording button then it displays to give
the Testcase name provide the name (Ex:testcase_1).
• Once you run the testcase the website will be directly opened and logged In.
• Then in the IDE it will display as ‘testcase_1’completed successfully.
Program 9 - Test Suite: Conduct a test suite for any two web sites.
Step 1:
• Open SeleniumIDE.
• Click on ok.
Step 2:
• Now in the right side of the panel select “Test suites” .
• In the same panel we can see this “+” symbol click on that.
• After clicking it ask us to Add new suite then give name to the test suites
(Ex:lab9_test).
Step 3:
• As we created a test suites in the same way select on “Tests” and click on
“+” .Give name to the test (Ex:test_case1).
• Then click on add button.
Step 4:
https://www.saucedemo.com/
Step 5:
• Create a new test case(Ex:test_case2).
Step 6:
• https://the-internet.herokuapp.com/login
Step 7:
• Now add the test cases to the already created test suite as lab9_test.
Step 8:
• Click on run all tests button
• Then you can see the testcases running.
After that will display as “completed successfully”.
Program 10 - Test Scripts: Develop and test a program to login a
specific web page using selenium test scripts.
Step 1:
• Open the VScode .
• Create a new file in a selenium folder, that was already in C-drive.
• Name the file (Ex: program_10.py).
driver = webdriver.Chrome()
driver.get("https://opensource-demo.orangehrmlive.com/web/index.php/auth/login")
driver.find_element(By.NAME, "password").send_keys("admin123")
driver.find_element(By.XPATH, "//button[@type='submit']").click()
time.sleep(5)
if "dashboard" in driver.current_url:
else:
print("Login Test Failed")
# Close browser
driver.quit()
Once the code is executed, the URL provided in the code opens directly in chrome and
automatically takes username and password , then you will be logged in.
# Initialize WebDriver
driver = webdriver.Chrome()
driver.get("https://demoqa.com/")
# Find all elements on the page
total_elements = len(all_elements)
# Print total count
try:
tag_name = element.tag_name
element_text = element.text.strip()
except:
print(f"{index}. <Unknown Element>")
# Close browser
driver.quit()
• This website will be opened and searches for the tools which are in this site.
• In terminal you can see this output.
Program 12 - Practical Exercise and Wrap-Up: Build Test suit
with suitable application and complete end to end automation
process, Discussion on Best Practices and Q&A.
Step 1:
• Open the VScode .
• Create a new file in a selenium folder, that was already in C-drive.
• Name the file (Ex: program_12.py).
Type the given code:
import time
def run_test():
# Setup
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)
driver.maximize_window()
try:
# Step 1: Navigate to site
driver.get("https://practicetestautomation.com/practice-test-login/")
driver.find_element(By.ID, "username").send_keys("student")
driver.find_element(By.ID, "password").send_keys("Password123")
driver.find_element(By.ID, "submit").click()
else:
except Exception as e:
driver.save_screenshot("error_screenshot.png")
finally:
time.sleep(2)
driver.quit()
if __name__ == "__main__":
run_test()
Output: