Demo Application For Automation Testing

Share

Demo application for automation testing

 I’ll provide you with a simple demo application for automation testing. For this example, let’s create a basic web application: a login page with username and password fields.

Demo Application: Login Page

HTML Structure:

html
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
</head>
<body>
<h1>Welcome to the Demo Login Page</h1>
<form id="loginForm" action="/login" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<br>
<input type="submit" value="Login">
</form>
</body>
</html>

This login page is a simple HTML form with two input fields for the username and password, and a submit button for logging in.

Now, let’s assume we are using Selenium WebDriver (a popular tool for web automation) with Python to automate the testing of this login page.

Python Script using Selenium WebDriver:

python

from selenium import webdriver

# Replace 'path_to_webdriver' with the actual path to the WebDriver executable (e.g., chromedriver.exe)
driver = webdriver.Chrome(executable_path='path_to_webdriver')

# Load the login page
driver.get('http://localhost:8000/login') # Assuming the application is running locally on port 8000

# Test Case 1: Valid login credentials
username_input = driver.find_element_by_id('username')
password_input = driver.find_element_by_id('password')
login_button = driver.find_element_by_xpath('//input[@type="submit"]')

username_input.send_keys('demo_user')
password_input.send_keys('demo_password')
login_button.click()

# Check if login was successful
if driver.current_url == 'http://localhost:8000/dashboard':
print('Test Case 1 Passed: Successfully logged in')
else:
print('Test Case 1 Failed: Login unsuccessful')

# Test Case 2: Invalid login credentials
driver.get('http://localhost:8000/login') # Start from the login page again

username_input.send_keys('wrong_user')
password_input.send_keys('wrong_password')
login_button.click()

# Check if login failed with incorrect credentials
if driver.current_url == 'http://localhost:8000/login':
print('Test Case 2 Passed: Invalid login handled correctly')
else:
print('Test Case 2 Failed: Login did not fail with incorrect credentials')

# Close the browser
driver.quit()

This Python script demonstrates two test cases: one with valid login credentials and another with invalid login credentials. The Selenium WebDriver interacts with the web elements (input fields and submit button) to input data and perform the login process. It then checks whether the login was successful or not by verifying the URL after the login attempt.

Please note that in a real-world scenario, you would integrate this test script with a testing framework (e.g., Pytest, Unittest) and also use explicit waits, error handling, and other best practices for more robust and maintainable automation testing.

Demo Day 1 Video:

 
You can find more information about Selenium in this Selenium Link

 

Conclusion:

Unogeeks is the No.1 IT Training Institute for Selenium Training. Anyone Disagree? Please drop in a comment

You can check out our other latest blogs on  Selenium here – Selenium Blogs

You can check out our Best In Class Selenium Training Details here – Selenium Training

💬 Follow & Connect with us:

———————————-

For Training inquiries:

Call/Whatsapp: +91 73960 33555

Mail us at: info@unogeeks.com

Our Website ➜ https://unogeeks.com

Follow us:

Instagram: https://www.instagram.com/unogeeks

Facebook:https://www.facebook.com/UnogeeksSoftwareTrainingInstitute

Twitter: https://twitter.com/unogeeks


Share

Leave a Reply

Your email address will not be published. Required fields are marked *