You are on page 1of 10

February 5, 2021

Assignment SQA
SQA; Use Cases And Test Cases
https://www.booking.com/
User Registration:
Descriptions and priority:
User registration will allow the users to create an account on their platform in order to
access the available options
User will provide:
Email
The system will check if the email already exists in the database if so, it will prompt an error
if not user will provide a secure password and the account will be created
Source:
The email can be provided either by the user or by google or Facebook if the user says so
Preconditions:
None
Postconditions:
The user will be successfully registered

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import io.github.bonigarcia.wdm.WebDriverManager;

public class Register {

public static void main(String[] args) {

WebDriverManager.chromedriver().setup();
WebDriver driver=new ChromeDriver();
String URL="http://automationpractice.com/index.php";

driver.get(URL);
driver.manage().timeouts().implicitlyWait(2000, TimeUnit.MILLISECONDS);
driver.manage().window().maximize();

driver.findElement(By.name("username")).sendKeys("Test User");
// Validate that user has created
if(userText.contains("Vsoft")) {
System.out.println("User Verified,Test case Passed");
}
else {
System.out.println("User Verification Failed,Test case Failed");
}
}
}

Forgot Password:
Description:
The link Forgot password is available in the login box on the home page. User can reset
[password here.
Inputs:
User Email, Email Password
Source:
All inputs are provided by the user.
Outputs:
User can either reset password or not.
PreConditions:
User must be registered.
PostConditions:
User clicks on the link “Forgot Password in the login box.
package com.example.hotmail.model;
import com.example.Page;

import com.example.Page;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class ForgotPassword extends Page {

private final String TITLE = "Reset your password";


public ResetPasswordPage(WebDriver driver) {
super(driver);
}

@Override
public String getTitle() {
return TITLE;
}

/**
* Sets account name
*
public void setAccountName(String name) {
WebElement accountName =
driver.findElement(By.xpath("//input[@id='iMemberName']"));
accountName.sendKeys(name);
}

/**
* Waits for reset option to be available
*/
private void waitForResetPasswordOptions() {
(new WebDriverWait(driver, TIMEOUT))
.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return driver.findElements(

By.xpath("//input[@id='idProofEmail']")).size() > 0;
}
});
}

/**
* Resets account password by sending email to
* another account setup during enrollment.
*
public boolean selectEmailMeResetLink() {
waitForResetPasswordOptions();

WebElement opt =
driver.findElement(By.xpath("//input[@id='idProofEmail']"));
opt.click();
sleep(1000);
WebElement next =
driver.findElement(By.xpath("//input[@id='idEmailSubmit']"));
next.click();
final String email_sent = "//div[contains(., \"We've sent a password reset
link to these email addresses.\")]";
try {
(new WebDriverWait(driver, TIMEOUT))
.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return
driver.findElements(By.xpath(email_sent))
.size() > 0;
}
});
} catch (Exception ignore) {}

if (driver.findElements(By.xpath(email_sent)).size() > 0)
return true;
Else
return false;

}
}

Reset Password:
Description:
User can change password here.
Inputs:
Enter password, Confirm password
Source:
All inputs are provided by the user.
System sends and verify the account via mail.
Outputs:
User can either change password or not.
Pre Conditions:
User must be registered.
Post Conditions:
User click on the link “Reset” in the account setting
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class ResetPassword


{
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver","specify your chromedriver.exe path
here");
WebDriver driver = new ChromeDriver();
String URL = "Your site url";
driver.get(URL);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

//Old Password
driver.findElement(By.xpath("Old Password Field xpath here")).sendKeys("old
password");
driver.findElement(By.xpath("New Password Field xpath here")).sendKeys("new
password");
driver.findElement(By.xpath("Re-enter Password Field xpath here")).sendKeys("new
password");
driver.findElement(By.xpath("Submit button xpath")).click();
}
}

Rent a Car
Description:
User can book a car on rent
Inputs:
From date, To date, Booking details
Source:
All inputs are provided by the user.
Outputs:
User will rent a car
Pre Conditions:
User must be logined.
Banking details should be correct
Post Conditions:
User trigger Event will be User clicks on the button “Book for late” on the web page.
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys

S
class TestMaintest():
def setup_method(self):
self.driver = webdriver.Chrome()
#self.driver.setSpeed(2000);
self.vars = {}

def teardown_method(self):
self.driver.quit()

def loginpositivecustomer(self):
self.driver.get("http://localhost:5000/")
self.driver.find_element(By.LINK_TEXT, "Sign In").click()
self.driver.find_element(By.ID, "name").send_keys("abiali")
self.driver.find_element(By.ID, "passw").send_keys("root")
self.driver.find_element(By.NAME, "proceed").click()

def test_payment(self):
self.driver.find_element(By.ID, "third").click()
self.driver.find_element(By.NAME, "debit").click()
self.driver.find_element(By.ID, "card_no").click()
self.driver.find_element(By.XPATH,
"//*[@id=\"horizontalTab\"]/div[2]/div[3]/div/form/div[2]/div/label/i").click()
self.driver.find_element(By.ID, "submit").click()

def test_booking(self):
self.driver.find_element(By.NAME, "userId").send_keys("abiali")
dropdown = self.driver.find_element(By.ID, "cab")
dropdown.find_element(By.XPATH, "//option[. = 'Sedan Cab(5 Seater)']").click()
self.driver.find_element(By.NAME, "startDate").send_keys("28/9/2019")
self.driver.find_element(By.NAME, "endDate").send_keys("29/9/2019")
self.driver.find_element(By.NAME, "time").send_keys("8:00")
self.driver.find_element(By.ID, "submit").click()

def test_invoice(self):
self.driver.find_element(By.XPATH,
"/html/body/div[1]/form/div[3]/center/h2/nav/a").click()

def test_maintest(self):
self.loginpositivecustomer()
self.test_booking()
self.test_payment()
self.test_invoice()

main=TestMaintest()
main.setup_method()
main.test_maintest()
main.teardown_method()

You might also like