Ccs366 Sta Lab Final

Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

MOHAMED SATHAK A.

J COLLEGE OF ENGINEERING

(Approved by AICTE,New Delhi and Affiliated to Anna University)


34, Old Mahabalipuram Road, Egattur, Chennai – 603103.

ISO 9001:2008 Certified Institution

Sponsored By: MOHAMED SATHAK TRUST, Chennai –600034.

(ACADEMICYEAR: 2022-2023)

CCS366 – SOFTWARE TESTING AND AUTOMATION LABORATORY

Name :

Register Number :

Department : INFORMATION TECHNOLOGY

Year/Semester : III/V

(ANNA UNIVERSITY:CHENNAI-600025)
MOHAMED SATHAK A.J COLLEGE OFENGINEERING
(Approved by AICTE,New Delhi and Affiliated to Anna University)34,Old
Mahabalipuram Road,Egattur,Chennai–603103.

ISO9001:2008 Certified Institution

Sponsored By: MOHAMED SATHAK TRUST,

Chennai–600034.

BONAFIDE CERTIFICATE

This is to certify that this is the Bonafide Record of work done by


Mr./Ms......................................................……………….

Register Number ................................................................................................... of


IIIYEAR/V Semester – INFORMATION TECHNOLOGY
CCS366 – SOFTWARE TESTING AND AUTOMATION LABORATORY during the academic year
2022-2023.

StaffIn-Charge Head of the Department

Submitted for the Anna University B.E Practical Examination held on.
.................................

Internal Examiner External Examiner


INDEX PAGE
LIST OF EXPERIMENTS

Ex.No Date Name of the Experiment Page No Signature

10

3
Exp.No.1 To create checklist for developing and testing e-commerce web and mobile
application
Date:

Aim
1. To create checklist for testing e-commerce web and mobile application
E-Commerce Testing Checklist:
Important segments and test cases for e-Commerce website testing need to be listed as below
1. Home Page – Hero Image
Homepages of retail sites are very important. Almost all of them have a Hero Image. This is the kind of the
clickable image (a slideshow of sorts) that occupies the majority of the page.
The following are a few things to test:
 Is it going to auto scroll?
 If yes, at what interval will the image be refreshed?
 When the user hovers over it, is it still going to scroll to the next one?
 Can it be hovered on?
 Can it be clicked on?
 If yes, is it taking you to the right page and right deal?
 Is it loading along with the rest of the page or loads last in comparison to the other elements on the
page?
 Can the rest of the content be viewed?
 Does it render the same way in different browsers and different screen resolutions?

2. Search
Search algorithms are very important for the success of a retail site because we can’t always place what the
users want to see right in front.

4
Common tests are:

 Search based on the Product name, brand name, or something more broadly, the category. For
example Camera, Canon EOS 700D, electronics, etc.
 Search Results have to be relevant
 Different sort options have to be available- based on Brand, Price, and Reviews/ratings etc.
 How many results to display per page?
 For multi-page results, are there options to navigate to them
 Also, search happens in many places.
 The search drilling down into multiple levels into consideration when validating this functionality.
For example: When I search on the home page, I might see something like this:

3. Product Details Page


Once a user finds a product either through search or by browsing or by clicking on it from the homepage,
the user will be taken to the product information page.
Check:
 Image or images of the product
 Price of the product
 Product specifications
 Reviews
 Check out options
 Delivery options
 Shipping information
 In-stock/Out of stock
 Multiple color or variations options
 Breadcrumb navigation for the categories (highlighted in Red below). If navigation such as that is
displayed, make sure every element of it is functional.

5
4. Shopping Cart
This is the penultimate stage before the user commits to the purchase.
Test the following:
 Add items to the cart and continue shopping
 If the user adds the same item to the cart while continuing to shop, the item count in the shopping
cart should get incremented
 All items and their totals should be displayed in the cart
 Taxes as per location should be applied
 A user can add more items to the cart- total should reflect the same
 Update the contents added to the cart- total should reflect that too
 Remove items from the cart
 Proceed to checkout
 Calculate Shipping costs with different shipping options
 Apply coupons
 Don’t check out, close the site, and come back later. The site should retain the items in the cart

6
5. Payments

 Check different payment options


 If allowing check out as Guest, simply finish the purchase and provide an option to register at the
end
 Returning customers – Login to check out
 User sign up
 If storing customer Credit card or any other financial information, perform security testing around
this to make sure it is secure.(PCI compliance is a must)
 If the user is signed up for a long time, make sure the session is timed out or not. Every site has a
different threshold. For some, it is 10 minutes. For some, it might be different.
 Emails/Text confirmation with the order number generated

7
6. Categories/Featured Products/Related or Recommended Products
 Since these are dynamic elements, the best way to test these parts of the application is to test the
algorithm based on which these sections are populated.
 Check your Data mining/BI systems and check from the backend the queries that populate these
sections.

7. After-Order Tests
Check:
 Change the Order
 Cancel the Order
 Track the Order
 Returns

Result:
Checklist for developing test plan for testing e-commerce web and mobile application are created and
checked.

8
Exp.No.2 To develop test plan document for testing e-commerce or banking web and
mobile application
Date:

Aim
1. To develop test plan document for testing e-commerce or banking web and mobile application
1)Introduction
The Test Plan is designed to prescribe the scope, approach, resources, and schedule of all testing activities
of the project Guru99 Bank.
The plan identify the items to be tested, the features to be tested, the types of testing to be performed, the
personnel responsible for testing, the resources and schedule required to complete testing, and the risks
associated with the plan
1.1) Scope
1.1.1) In Scope
All the feature of websiteGuru99 Bank which were defined in software requirement specs are need to be
tested

9
1.1.2) Out of Scope
These feature are not be tested because they are not included in the software requirement specs

 User Interfaces
 Hardware Interfaces
 Software Interfaces
 Database logical
 Communications Interfaces
 Website Security and Performance
1.2) Quality Objective
The test objectives are to verify the Functionality of website Guru99 Bank, the project should focus on
testing the banking operation such as Account Management, Withdrawal, and Balance…etc. to guarantee
all these operation can work normally in real business environment.
1.3) Roles and Responsibilities
The project should use outsource members as the tester to save the project cost.

10
2 Test Methodology
2.1 Overview
2.2 Test Levels
In the project Guru99 Bank, there’re 3 types of testing should be conducted.

 Integration Testing (Individual software modules are combined and tested as a group)
 System Testing: Conducted on a complete, integrated system to evaluate the system’s compliance
with its specified requirements
 /api-testing.html: Test all the APIs create for the software under tested
2.3 Bug Triage
2.4 Suspension Criteria and Resumption Requirements
If the team members report that there are 40% of test cases failed, suspend testing until the development
team fixes all the failed cases.
2.5 Test Completeness

 Specifies the criteria that denote a successful completion of a test phase


 Run rate is mandatory to be 100% unless a clear reason is given.
 Pass rate is 80%, achieving the pass rate is mandatory
2.6 Project task and estimation and schedule

Schedule to complete these tasks


3 Test Deliverables
Test deliverables are provided as below

 Before testing phase


 Test plans document.
 Test cases documents
 Test Design specifications.
 During the testing

11
– Test Tool Simulators.
– Test Data
– Test Trace-ability Matrix – Error logs and execution logs.
After the testing cycles is over
 Test Results/reports
 Defect Report
 Installation/ Test procedures guidelines
 Release notes
4 Resource & Environment Needs
4.1 Testing Tools

4.2 Test Environment


It mentions the minimum hardware and software requirements that will be used to test the Application.
Following software’s are required in addition to client-specific software.

 Windows 11 and above


 Office 2021 and above
 MS Exchange, etc.

Result:
Test plan document for testing e-commerce or banking web and mobile application was created.

12
Exp.No.3 To create test cases for testing e-commerce or any web and mobile application

Date:

Aim
1. To develop test cases for testing e-commerce or any web and mobile application
Test Scenario - Login

13
Test Scenario – Purchase

14
Test Scenario – Search

Result:
Test cases for testing e-commerce or any web and mobile application was developed

15
Exp.No.4 Design Front-end for any web application and derive the test cases as

Date: Applicable. Validate the UI elements using JavaScript.

Aim
To Design Front-end for any web application and derive the test cases as applicable. Validate the UI
elements using JavaScript.
Program
1. HTML
<html>
<head>
<title>Javascript Login Form Validation</title>
<!-- Include CSS File Here -->
<link rel="stylesheet" href="form-style.css"/>
<!-- Include JS File Here -->
<script src="login.js"></script>
</head>
<body>
<div class="container">
<div class="main">
<h2>Javascript Login Form Validation</h2>
<form id="form_id" method="post" name="myform">
<label>User Name :</label>
<input type="text" name="username" id="username"/>
<label>Password :</label>
<input type="password" name="password" id="password"/>
<input type="button" value="Login" id="submit" onclick="validate()"/>
</form>
<span><b class="note">Note : </b>For this demo use following username and password.
<br/><b class="valid">User Name : Form<br/>Password : 123</b></span>
</div>
</div>
</body>
</html>

16
2. login.js:

var attempt = 3; // Variable to count number of attempts.


// Below function Executes on click of login button. function validate() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if ( username =="Form" && password =="123") { alert ("Login successfully");
window.location = "success.html"; // Redirecting to other page. return false;
}
else {
attempt --; // Decrementing by one. I alert("You have left "+attempt+" attempt;");
// Disabling fields after 3 attempts. if( attempt == 0){
document.getElementById("username").disabled = true; document.getElementById("password").disabled
= true; document.getElementById("submit").disabled = true; return false;
}
}
}

3.Success.html
<html>
<head>
<title>Javascript Login Form Validation</title>
</head>
<body>
<h2>Successful Login!</h2>
</body>
</html>

17
Output

Logged in successfully.

Login failed, so the number of attempts is displayed.

18
Result
Front-end for web application is developed and testcases is derived. Validated the UI elements using
JavaScript.

19
Exp.No.5 Install and implement test script in Selenium IDE using recording,
playing back / executing and solving resources / processes.
Date:

Aim
To install and implement test script in Selenium IDE using recording, playing back / executing and
solving resources / processes.
Installing IDE

 Step 1: Open the Firefox browser.


 Step 2: Click on the menu in the top right corner. Step 3: Click on add-ons in the drop down box.
 Step 4: Click on “Find more add-ons” and type “Selenium-IDE”. Step 5: Click on “Add to
Firefox”.
 Once installed, the selenium IDE icon appears on the top right corner of the browser. Once you
click on it , a welcome message appears.
Recording a test

 Step 1: Provide a name for your project


 Step 2: Before recording, specify a valid URL. The recording begins once the browser navigates
to this URL.
 Step 3: Clicking on „Start recording‟ will redirect to the specified URL and start recording the
user interactions.
 The user is at liberty to stop the recording. All user actions are recorded and converted into a
script.
Save the work

 Step 1: Click the save icon in the top right corner of the IDE.
 Step 2: It will prompt for name and a location of where to save the project. The result is a single
file with a side extension.
Playback
In browser, the tests can be played back in the Selenium automation testing IDE by selecting the test to
play and by clicking on the play button.

20
Output

21
Result

Selenium IDE was installed successfully and implemented test script using recording, playing
back / executing and solving resources / processes.

22
Exp.No.6 Creating Selenium IDE Tests - Recording and Adding Commands in a
Test
Date:

Aim
To create selenium IDE tests and to record or add commands in a test
The following steps are involved in creating Selenium tests using IDE:

 Recording and adding commands in a test


 Saving the recorded test
 Saving the test suite
 Executing the recorded test
Recording and Adding Commands in a Test
We use www.ncalculators.com to demonstrate the features of Selenium.

 Launch the Firefox browser and navigate to the website –


 http://www.ncalculators.com/
Open Selenium IDE from the Tools menu and press the record button that is on the top-right corner.
Navigate to "Math Calculator" >> "Percent Calculator >> enter "10" as number1 and 50 as number2 and
click "calculate".
User can then insert a checkpoint by right clicking on the web element and select "Show all available
commands" >> select "assert text css=b 5"
The recorded script is generated and the script is displayed as shown below.

Saving the Recorded Test


Save the Test Case by navigating to "File" >> "Save Test" and save the file in the location of your choice.
The file is saved as .HTML as default.
The test can also be saved with an extension htm, shtml, and xhtml.
Saving the Test Suite
A test suite is a collection of tests that can be executed as a single entity.
Create a test suite by navigating to "File" >> "New Test Suite" as shown below.
The tests can be recorded one by one by choosing the option "New Test Case" from the "File" Menu.
The individual tests are saved with a name along with saving a "Test Suite".

23
Executing the Recorded Test
The recorded scripts can then be executed either by clicking "Play entire suite" or "Play current test"
button in the toolbar
The Run status can be seen in the status pane that displays the number of tests passed and failed.
Once a step is executed, the user can see the result in the "Log" Pane.
After executing each step, the background of the test step turns "Green" if passed and "Red" if failed as
shown below

24
Output

25
26
Result
Selenium IDE tests was created and to recorded or added commands in a test.

27
Exp.No.7 Debug scripts with Selenium IDE

Date:

Aim
To debug scripts by using selenium IDE
Debugging is the process of finding and fixing errors in the test script. It is a common step in any script
development. To make the process more robust, we can use a plugin "Power Debugger" for Selenium
IDE.
Steps
To install Power Debugger for Selenium IDE, navigate to https://addons.mozilla.org/en-
US/firefox/addon/power-debugger-selenium-ide/ and click "Add to Firefox" as shown below.
Now launch 'Selenium IDE' and you will notice a new icon, "Pause on Fail" on the recording toolbar as
shown below. Click it to turn it ON. Upon clicking again, it would be turned "OFF".
Users can turn "pause on fail" on or off any time even when the test is running.
Once the test case pauses due to a failed step, you can use the resume/step buttons to continue the test
execution. The execution will NOT be paused if the failure is on the last command of any test case.
We can also use breakpoints to understand what exactly happens during the step. To insert a breakpoint on
a particular step, "Right Click" and select "Toggle Breakpoint" from the context-sensitive menu.
Upon inserting the breakpoint, the particular step is displayed with a pause icon as shown below. When we
execute the script, the script execution is paused where the breakpoint is inserted. This will help the user to
evaluate the value/presence of an element when the execution is in progress.

28
Output

29
Result
Scripts was debugged with selenium IDE successfully.

30
Exp.No.8 Installing TestNG for Eclipse

Date:

Aim
To install TestNG by using eclipse
Steps
Launch Eclipse and select 'Install New Software'.
Enter the URL as 'http://beust.com/eclipse' and click 'Add'.
The dialog box 'Add Repository' opens. Enter the name as 'TestNG' and click 'OK'.
Click 'Select All' and 'TestNG' would be selected as shown in the figure.
Click 'Next' to continue.
Review the items that are selected and click 'Next'.
"Accept the License Agreement" and click 'Finish'.
TestNG starts installing and the progress would be shown follows.
Security Warning pops up as the validity of the software cannot be established. Click 'Ok'.
The Installer prompts to restart Eclipse for the changes to take effect. Click 'Yes'.

31
Output

32
Result
TestNG installed using eclipse successfully.

33
Exp.No.9 Setting up TestNG and Eclipse and load Java program.

Date:

Aim
To set up TestNG and Eclipse and load java program in it.
Steps
Launch Eclipse and create a 'New Java Project' as shown below.
Enter the project name and click 'Next'.
Navigate to "Libraries" Tab and Add the Selenium Remote Control Server JAR file by clicking on "Add
External JAR's" as shown below.
The added JAR file is shown here. Click 'Add Library'.
The 'Add Library' dialog opens. Select 'TestNG' and click 'Next' in the 'Add Library' dialog box.
The added 'TestNG' Library is added and it is displayed as shown below.
Upon creating the project, the structure of the project would be as shown below.
Right-click on 'src' folder and select New >> Other.
Select 'TestNG' and click 'Next'.
Select the 'Source Folder' name and click 'Ok'.
Select the 'Package name', the 'class name', and click 'Finish'.
The Package explorer and the created class would be displayed.

34
Output

35
Result
TestNG and Eclipse set up was created and loaded with Java jdk program.

36
Exp.No.10 Testing in TestNG for Usecase Percent Calculator

Date:

Aim
To use TestNG and run testing for percent calculator

Note: We will use the demo application, www.calculator.net, and perform percent calculator.In the
following test, you will notice that there is NO main method, as testNG will drive the program execution
flow. After initializing the driver, it will execute the '@BeforeTest' method followed by '@Test' and then
'@AfterTest'. Please note that there can be any number of '@Test' annotation in a class but '@BeforeTest'
and '@AfterTest' can appear only once.

Program
package TestNG;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestNGClass {
WebDriver driver = new FirefoxDriver();
@BeforeTest
public void launchapp() {
// Puts an Implicit wait, Will wait for 10 seconds before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// Launch website
driver.navigate().to("http://www.calculator.net");
driver.manage().window().maximize();
}
@Test
37
public void calculatepercent() {
// Click on Math Calculators
driver.findElement(By.xpath(".//*[@id='menu']/div[3]/a")).click();

// Click on Percent Calculators


driver.findElement(By.xpath(".//*[@id='menu']/div[4]/div[3]/a")).click();

// Enter value 10 in the first number of the percent Calculator


driver.findElement(By.id("cpar1")).sendKeys("10");

// Enter value 50 in the second number of the percent Calculator


driver.findElement(By.id("cpar2")).sendKeys("50");

// Click Calculate Button


driver.findElement(By.xpath(".//*[@id='content']/table/tbody/tr/td[2]/input")).click();

// Get the Result Text based on its xpath


String result =
driver.findElement(By.xpath(".//*[@id='content']/p[2]/span/font/b")).getText();

// Print a Log In message to the screen


System.out.println(" The Result is " + result);

if(result.equals("5")) {
System.out.println(" The Result is Pass");
} else {
System.out.println(" The Result is Fail");
}
}

38
@AfterTest
public void terminatetest() {
driver.close();
}
}

Execution
1. To execute, right click on the created XML and select "Run As" >> "TestNG Suite"
2. The output is thrown to the console and it would appear as shown below. The console output also has
an execution summary.

39
Output

40
Result
TestNG suit was used and executed testing for percent calculator usecase successfully.

41

You might also like