ASE Lab

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

Advanced Software Engineering Lab Report

A Report submitted in partial fulfilment of the Requirements for the award of the degree of
Bachelor of Technology in
INFORMATION TECHNOLOGY

Submitted by:
Tanishq Verma
Roll No. 12112001
Branch: IT

Supervised by:
Dr. Vinay Pathak
(Assistant Professor)

INDIAN INSTITUTE OF INFORMATION TECHNOLOGY, SONEPAT – 131201,


HARYANA, INDIA
INDEX

S.No. Experiment Date Sign


1 Understanding manual testing through excel. 18-01-24
2 Understanding the core concept of Browser driver classes and 18-01-24
Webdriver interface.
3 Run tests in Browser like Google Chrome, Microsoft Edge 25-01-24
4 Getting started with basic Selenium WebDriver methods. 01-02-24
5 Identifying the web elements using following locators (with 08-02-24
live examples):
• Id
• Xpath
• Css selectors
• Name
• Classname
• TagName
• Link Text
6 Techniques to identify objects using regular Expressions. 15-02-24
7 Explore functional testing using Selenium. 22-02-24
8 Docker installation – windows/ubuntu/EC2 29-02-24
9 Operations on images- 07-03-24
• Pull a centos/ubuntu image from docker hub
• Create a container for the pulled images
10 Finding number of images, containers running on host machine 14-03-24
and various relevant operations such as –
• Finding number of processes running vs process
running inside container.
• Existing container, renaming container, collecting
container statistics, removing container history, inspect
11 Pulling, removing, zipping, tagging various docker images 21-03-24
12 Creating a Docker image without Dockerfile 04-04-24
13 Practice basic Dockerfile directives 11-04-24
14 Practice containerizing using Dockerfiles 18-04-24
Experiment 1

Understanding manual testing through excel.

A Test Case Template is a well-designed document for developing and better understanding of the
test case data for a particular test case scenario. A good Test Case template maintains test artifact
consistency for the test team and makes it easy for all stakeholders to understand the test cases.
Writing test case in a standard format lessen the test effort and the error rate. Test cases format are
more desirable in case if you are reviewing test case from experts.
The template chosen for your project depends on your test policy. Many organizations create test
cases in Microsoft Excel while some in Microsoft Word.

Irrespective of the test case documentation method chosen, any good test case template must have
the following fields:

Test Case Description


Field
Test case Each test case should be represented by a unique ID. To indicate test types
ID: follow some convention like “TC_UI_1” indicating “User Interface Test
Case#1.”
Test It is useful while executing the test.
Priority:
• Low
• Medium
• High

Name of Determine the name of the main module or sub-module being tested
the
Module:
Test Tester’s Name
Designed
by:
Date of test Date when test was designed
designed:
Test Who executed the test- tester
Executed
by:
Date of the Date when test needs to be executed
Test
Execution:
Name or Title of the test case
Test Title:
Descriptio Determine the summary or test purpose in brief
n/Summar
y of Test:
Pre- Any requirement that needs to be done before execution of this test case.
condition: To execute this test case list all pre-conditions
Dependenc Determine any dependencies on test requirements or other test cases
ies:
Test Steps: Mention all the test steps in detail and write in the order in which it requires to be executed.
While writing test steps ensure that you provide as much detail as you can.
Test Data: Use of Test Data as an input for the test case. Deliver different data sets with precise values
to be used as an input
Expected Mention the expected result including error or message that should appear on screen
Results:
Post- What would be the state of the system after running the test case?
Condition:
Actual After test execution, actual test result should be filled
Result:
Status Mark this field as failed, if actual result is not as per the estimated result
(Fail/Pass):
Notes: If there are some special condition which is left in above field

Test Case ID BU_001 Test Case Test the Login Functionality in Banking
Description
Created By Mark Reviewed By Bill Version 2.1

QA Tester’s Log Review comments from Bill incorprate in


version 2.1

Tester's Name Mark Date Tested 1-Jan-2017 Test Case Pass


(Pass/Fail/Not
Executed)

S# Prerequisites: S# Test Data


1 Access to Chrome Browser 1 Userid = mg12345
2 2 Pass = df12@434c
3 3
4 4

Test Verify on entering valid userid and password, the customer can
Scenario login

Step # Step Details Expected Results Actual Results Pass / Fail / Not executed /
Suspended
1 Navigate to Site should open As Expected Pass
http://demo.guru99.com
2 Enter Userid & Password Credential can be As Expected Pass
entered
3 Click Submit Cutomer is logged As Expected Pass
in
4
Experiment 2

Understanding the core concept of Browser driver classes and Webdriver interface.

Browser Driver:
For each browser you aim to automate using Selenium, a corresponding browser driver is essential.
These drivers serve as intermediaries, facilitating seamless communication between Selenium and the
browser. For Chrome, you would require chromedriver.exe (on Windows) or chromedriver (on
macOS/Linux), provided by the respective browser vendors like Google for Chrome and Mozilla for
Firefox.
These browser drivers have the capability to control the browser but don’t inherently know what
actions to perform. That’s where Selenium comes into play. Through the WebDriver instance,
Selenium directs the browser driver, specifying actions like opening a web page or clicking a button.

WebDriver Interface:
Selenium WebDriver is an interface that defines a set of methods. However, implementation is
provided by the browser specific classes. Some of the implementation classes
are AndroidDriver, ChromeDriver, FirefoxDriver, InternetExplorerDriver, IPhoneDriver, SafariDriver
etc. The WebDriver main functionality is to control the browser. Kinda like a remote control. It even
helps us to select the HTML page elements and perform operations on them such as click, filling a
form fields etc.
Experiment 3

Run tests in Browser like Google Chrome, Microsoft Edge.

Here we ran a test case to get title of a particular webpage, in this case https://iiitsonepat.ac.in,
using Chrome driver.

package org.example;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.WebDriver;

public class Main {


public static void main(String[] args) {

WebDriver driver = new ChromeDriver();


driver.get("https://iiitsonepat.ac.in");
System.out.println(driver.getTitle());
driver.quit();
}
}
Experiment 4

Getting started with basic Selenium WebDriver methods.

1. Start the session

WebDriver driver = new ChromeDriver();

2. Take action on browser

driver.get("https://www.selenium.dev/selenium/web/web-
form.html");

3. Request browser information

driver.getTitle();

4. Establish Waiting Strategy

driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));

5. Find an element

WebElement textBox = driver.findElement(By.name("my-text"));


WebElement submitButton =
driver.findElement(By.cssSelector("button"));

6. Take action on element

textBox.sendKeys("Selenium");
submitButton.click();

7. Request element information

message.getText();

8. End the session

driver.quit();
Experiment 5

Identifying the web elements usinf following locators (with live examples):
• Id
• Xpath
• Css selectors
• Name
• Classname
• TagName
• Link Text

1. ID:
• HTML element with a unique identifier.

<input id="username" type="text">


WebElement elementById =
driver.findElement(By.id("username"));

2. XPath:
• XML Path Language (XPath) allows for navigating through the XML structure of
an HTML document.

<button
xpath="//button[@class='submitButton']">Submit</button>
WebElement elementByXPath = driver.findElement(By.xpath
("//button[@class='submitButton']"));

3. CSS Selectors:
• CSS selectors allow for selecting HTML elements based on their attributes,
classes, or IDs.

<a href="https://www.example.com" class="nav-


link">Example</a>
WebElement elementByCss =
driver.findElement(By.cssSelector("a.nav-link"));

4. Name:
• HTML elements with a specified name attribute.

<input type="password" name="password">


WebElement elementByName =
driver.findElement(By.name("password"));

5. Classname:
• HTML elements with a specified class attribute.

<div class="container">
<p>Hello, World!</p>
</div>
WebElement elementByClass =
driver.findElement(By.className("container"));

6. Tag Name:
• HTML elements with a specified tag name.

<h1>Welcome to Example.com</h1>
WebElement elementByTagName =
driver.findElement(By.tagName("h1"));

7. Link Text:
• HTML anchor elements (<a>) with specific visible text.

<a href="https://www.example.com">Click here</a>


WebElement elementByLinkText =
driver.findElement(By.linkText("Click here"));
Experiment 6

Techniques to identify objects using regular Expressions.

Using regular expressions (regex) to identify objects in Selenium WebDriver can be helpful when
dealing with dynamic or changing attributes of web elements. Here are some techniques for using
regex with Selenium:

1.Partial Attribute Matching:

You can use regex to match only a part of an attribute value, which can be useful when the
attribute value contains dynamic or changing parts.

WebElement element =
driver.findElement(By.xpath("//input[contains(@id,
'username')]"));

2.Text Matching:

Regex can be used to match specific text within elements, especially when the text content is
dynamic or contains variable parts.

WebElement element =
driver.findElement(By.xpath("//a[contains(text(),
'Click')]"));

3.Combining with other locators:

You can combine regex-based locators with other locator strategies like CSS selectors, class
names, etc., for more precise element identification.

WebElement element =
driver.findElement(By.cssSelector("input[id^='user']"));
Experiment 7

Explore functional testing using Selenium.

What is Functional Testing?


Functionality Testing is exactly what it sounds like. Functional testing is possible at all system
levels, from unit testing to acceptance testing.

Types of Functional Testing

There are three primary Types of Functional Testing at the system and UI levels:

1. Smoke Testing: Smoke testing is a quick way to make sure your built is Functioning
Correctly. Every time you build your code, you should at the very least perform a smoke test,
even if no changes were made. Instead of extensively testing everything, this usually entails
going through the key user processes.

2. Regression Testing: Verifying that the product still Works As Intended after Recent
Changes is the goal of regression testing. This is crucial if you’ve changed the functionality
or introduced any new code. Additionally, if you have performed any problem fixes—and bug
patches have a nasty way of affecting other bits of code—it is necessary. This is a
significantly more time-consuming method that must test each moving component of your
software.

3. Integration Testing: Testing Newly Integrated system capabilities is known as integration


testing. If the additional functionality has a significant impact, this can occasionally be
difficult. Integration testing should be Conducted for both new UI Features and Backend and
core functionality.
Now, use Selenium to Automate Functional Testing by performing the actions listed below:

Example:

package org.example;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.WebDriver;

public class Main {


public static void main(String[] args) {

WebDriver driver = new ChromeDriver();


driver.get("https://iiitsonepat.ac.in");
System.out.println(driver.getTitle());
driver.quit();
}
}
Experiment 8

Docker installation – windows/ubuntu/EC2.

1. Download the installer using the download button provided on the official docker website.
2. Double-click Docker Desktop Installer.exe to run the installer. By default, Docker Desktop
is installed at C:\Program Files\Docker\Docker.
3. When prompted, ensure the Use WSL 2 instead of Hyper-V option on the Configuration
page is selected or not depending on your choice of backend.

If your system only supports one of the two options, you will not be able to select which backend
to use.
4. Follow the instructions on the installation wizard to authorize the installer and proceed
with the install.
5. When the installation is successful, select Close to complete the installation process.

If your admin account is different to your user account, you must add the user to the docker-
users group:
1. Run Computer Management as an administrator.
2. Navigate to Local Users and Groups > Groups > docker-users.
3. Right-click to add the user to the group.
4. Sign out and sign back in for the changes to take effect.
Experiment 9

Operations on images-

• Pull a centos/ubuntu image from docker hub


• Create a container for the pulled images

Images can be pulled from the docker hub using the “docker pull {imageName}” command.

The previously downloaded image can be used to run a container using the “docker run
{imageName}” command.
Experiment 10

Finding number of images, containers running on host machine and various relevant operations
such as –
• Finding number of processes running vs process running inside container.
• Existing container, renaming container, collecting container statistics, removing container
history, inspect

1. Finding the Number of Images:


• To find the number of Docker images on your host machine, you can use the docker
images command and count the output lines:

2. Finding the Number of Containers Running:


• To find the number of running Docker containers, you can use the docker ps command:

3. Finding the Number of Processes Running vs. Processes Running Inside Containers:
• To find the number of processes running on your host machine, you can use the ps
command. To find the number of processes running inside Docker containers, you can use
the docker top command for each running container and count the output lines.
4. Existing Container Operations:
• Renaming a Container:

• Collecting Container Statistics:

• Removing Container History:


Docker does not have a built-in command to remove container history. However, you can
prune all unused Docker objects, including containers, images, networks, and volumes,
using the docker system prune command:

• Inspecting a Container:
Experiment 11

Pulling, removing, zipping, tagging various docker images

Pulling Docker Images:


• To pull a Docker image from Docker Hub, you can use the docker pull command followed
by the image name and optionally the tag:

Removing Docker Images:


• To remove a Docker image from your local machine, you can use the docker rmi
command followed by the image name and tag:

Zipping Docker Images:


• Docker images are not stored as zip files, but you can save them as tar files using the
docker save command and then compress the tar file using any compression tool like gzip:
Tagging Docker Images:
• To tag a Docker image with a different name or version, you can use the docker tag
command:
Experiment 12

Creating a Docker image without Dockerfile.

1) Run a Container:
Start by running a Docker container based on an existing image. You can use the docker
run command to start a container from any image available on Docker Hub or locally on
your machine.

2) Install and Configure:


Once the container is running, you can install and configure any additional software or
make changes to the filesystem as needed. This could include installing packages,
modifying configuration files, etc.

3) Run Containers from the New Image:


Once the new Docker image is created, you can run containers from it using the docker
run command:
Experiment 13

Practice basic Dockerfile directives.

Dockerfile directives are instructions used to build Docker images. Some basic Dockerfile
directives along with their usage are:

1. FROM:
• The FROM directive specifies the base image for your Dockerfile. It's the starting point
for your image.

2. RUN:
• The RUN directive executes commands in the Docker image. It's used to install packages,
run scripts, etc.

3. COPY:
• The COPY directive copies files or directories from the host machine to the Docker image.

4. WORKDIR:
• The WORKDIR directive sets the working directory for any RUN, CMD, ENTRYPOINT,
COPY, and ADD instructions that follow it.

5. CMD:
• The CMD directive specifies the default command to run when a container is started.

6. EXPOSE:
• The EXPOSE directive informs Docker that the container listens on specific network ports
at runtime.

7. ENV:
• The ENV directive sets environment variables in the Docker image.

8. RUN vs. CMD:


• RUN is used during image build time to execute commands and modify the image
filesystem.
• CMD is used to define the default command to run when a container is started.
Experiment 14

Practice containerizing using Dockerfiles

I. Create a Dockerfile with all the necessary information regarding the image to be created.

II. Build the docker image using the docker build command
III. Now you can see the image stored using the docker images command

You might also like