quality assurance project
1
My Automation Test Plan: Foothill Bookstore Test
Automation Test Plan for Foothill College Bookstore
1. Test Plan Identifier: version 001, April 2018
2. Test Objective Due to frequent general merchandise products/venders discontinuation and updates, and due to duplicate products in outdated catalog database, it is very important to keep track and identify missing, misplaced, and mislabeled individual products. In this first version of automation test, we test for missing products and empty catalogs in our database. In addition, we check the error messages in the log.
3. Test Items First, we use the homepage (books.foothill.edu), page title “Home”, as baseURL and then identify search function by locating class name and tag id. By using keywords, we search the products which use the keyword in its name, title, or description. Then we use the login page trying to trigger an error use case, causing error messages. Finally, we test the string return (exact wording) of 4 different known error messages.
4. Test Strategy For automated item keyword search, to track down the specific items, keyword should be very specific but not limited. It could be the catalog name since the all items under the catalog should be picked up. Failing result from this test will show not only missing products but also which catalogs are well organized and which catalogs need to be reorganized or even recreated for easy access and products promotion. We also identify the login error messages. We examine the wording by identifying the combination of username and password. We also check if the messages are exactly the same as the default settings in order to check unauthorized or unrecognized update/change by unauthorized personals.
5. Tools Selenium IDE to identify id and cssSelector, Firefox to see the page source, Eclipse to use with selenium Webdriver, and Java to complete the script.
6. Environment Mozilla Firefox 45.0.2, Selenium IDE 2.9.1, Selenium Java WebDriver -2.53.0, Eclipse IDE Version Mars. 1 (4.5.1), JavaSE 1.8
7. Test Data List of product keywords/identifier. In this version of test data, java is written for the product keywords to be embedded directly into the java code but if the keywords become more than 50, all of the data will be stored in external .txt file with “,” delimiter. This data will be decided by our store manager and webmaster. Username and password combination data will be stored in java file for login error message check function. Java code will be introduced on page 4 - 6.
8. Risk and Assumptions Obvious risk will be network problems or potential item loading problems and time-outs. Automation testing has its limitation. It can identify failing items and problems but we still manually read the result and change/correct/update our database. We may need to rewrite the script frequently to adjust for the expected results and/or input data type
9. Result The result shows that Dell products are missing from our database. It may be the result from missing catalog for Dell and/or new products’ SKU numbers were not updated into insite server. We need to manually check database to add the missing SKU if there is any. The result also show missing catalog or products belong to “MWha!” since all of shakers are from this vendor. We need to manually add the SKU for these products. Login error messages were not affected by resent update. However, while creating this version of automated testing java code, we discovered the default error message has wording error. Username should be called “E-mail address” since we did not take unique username but e-mail address instead for login. This error needs to be corrected with MBS rep since those information is stored in their main server.
Title "Home" Test Passed!
ATTENTION!! Missing Product : Dell
Check Database and look for items relating "Dell" !!
ATTENTION!! Missing Product : shaker
Check Database and look for items relating "shaker" !!
There are 2 missing product(s). Database Test Failed!
username "" and password "" was passed.
Empty username field message: OK
username "" and password "validPSWD01" was passed.
Empty username field message: OK
username "invalid" and password "" was passed.
Invalid e-mail format message: OK
username "invalid" and password "validPSWD01" was passed.
Invalid e-mail format message: OK
username "invalid@" and password "" was passed.
Invalid e-mail format message: OK
username "invalid@" and password "validPSWD01" was passed.
Invalid e-mail format message: OK
username "[email protected]" and password "" was passed.
Empty password field message: OK
username "[email protected]" and password "validPSWD01" was passed.
Not a registered user message: OK
10. Integrations/Scheduling After running this first version of automation testing, we realized that we need to run the missing products test by using all of individual SKU numbers for the products we sell at our store to be more accurate. Due to missing products in the DB, we will schedule the automation tests at least twice a day. Scheduler will be set up in Jenkins to simulate Continuous Integration
// FirstTestCase.java
package automationFramework;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FirstTestCase {
private static WebDriver driver = new FirefoxDriver();
// default error message for the no item found
private static String sError = "We did not find any items that match your search. Please try another search.";
// list of product names (kinds) which should be available to view!
// this will be SKU numbers when we need to locate items which need to be removed.
private static String[] products = new String[]{"applecare", "macbook", "Adobe", "Calculator", "catalog", "iPad", "Dell", "shirt", "art kit", "owl", "Gift Certificate", "shaker"};
// expected error message for login attempt
private static String[] loginErrorMsgs = new String[]{"The username field was left blank. Please enter your username.",
"The email address you entered contains invalid characters. Please reenter in the form of a valid email address that is between six and 50 characters, and is without spaces. "
+ "Numbers/letters and _@ are acceptable. The characters are not case sensitive.",
"The password field was left blank. Please enter your password.", "ERROR: The login is not a registered user."};
public static void main(String[] args) {
driver.manage().window().maximize(); // maximize window
String baseUrl = "http://books.foothill.edu";
String expectedTitle = "Home";
String actualTitle = "";
// open firefox and open baseURL
driver.get(baseUrl);
// get actual title
actualTitle = driver.getTitle();
// page title test
if (actualTitle.contentEquals(expectedTitle)){
System. out .println("Title \"" + expectedTitle + "\" Test Passed!");
} else {
System. out .println("Title Test Failed!");
}
// search missing items from database
// call checkMissingProducts() function
checkMissingProducts();
// login error handling
// call function checkLoginErrorMsg() and write result
checkLoginErrorMsg();
// close firefox
driver.close();
// finish program
System.exit(0);
}
// function missing items database test
private static void checkMissingProducts(){
System. out .println(""); // one empty line for readability
int failNum = 0;
for(String product: products){
driver.findElement(By.id("search")).clear();
driver.findElement(By.id("search")).sendKeys(product);
driver.findElement(By.id("searchSubmit")).click();
// pause 2 seconds
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// If there is no item found, error message will appear. Check the text
String aError = driver.findElement(By.className("errors")).getText();
if(sError.equals(aError)){
System. out .println("ATTENTION!! Missing Product : " + product);
System. out .println("Check Database and look for items relating \"" + product + "\" !!");
failNum++; // count failed item
}
}
// count missing items and display result
if(failNum == 0){
System. out .println("No Missing Product. Database Test Passed!");
} else {
System. out .println("There are " + failNum + " missing product(s). Database Test Failed!");
}
}
// function login error message check
// check the error messages if it is displayed correctly as defined
private static void checkLoginErrorMsg(){
System. out .println(""); // one empty line for readability
String str = "";
// first, navigate to login page by clicking my account image
driver.findElement(By.cssSelector("#top_login_links > a > img")).click();
// create String array for user e-mail and password
String[] emails = new String[]{"", "invalid", "invalid@", "[email protected]"};
String[] passwds = new String[]{"", "validPSWD01"};
for (String email: emails){
driver.findElement(By.id("ctl00_ctl00_Content_Content_username")).clear();
driver.findElement(By.id("ctl00_ctl00_Content_Content_username")).sendKeys(email);
for(String passwd: passwds){
driver.findElement(By.id("ctl00_ctl00_Content_Content_password")).clear();
driver.findElement(By.id("ctl00_ctl00_Content_Content_password")).sendKeys(passwd);
driver.findElement(By.id("ctl00_ctl00_Content_Content_btnLogIn")).click();
System. out .println("username \"" + email + "\" and password \"" + passwd + "\" was passed.");
// pause 2 seconds (just for myself :)
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
String aemailError = driver.findElement(By.id("ctl00_ctl00_Content_Content_lblMessage")).getText();
if(aemailError.equals(loginErrorMsgs[0])){
System. out .println("Empty username field message: OK");
} else if(aemailError.equals(loginErrorMsgs[1])){
System. out .println("Invalid e-mail format message: OK");
} else if(aemailError.equals(loginErrorMsgs[2])){
System. out .println("Empty password field message: OK");
} else if(aemailError.equals(loginErrorMsgs[3])){
System. out .println("Not a registered user message: OK");
} else {
System. out .println("Unknown Message Displayed: ATTENTION!!");
}
}
}
}
}