Ch-7-Final Exam
Ch-7-Final Exam
Quality Assurance
2
The Classification Testing Tools
Software products can be classified to different types
based on different criteria (intended usage,
complexity, development technology, etc.)
The software testing tools can also be categorized,
depending on the licensing (paid or commercial,
open-source), technology usage, type of testing, and
so on.
With the help of testing tools, we can improve our
software performance, deliver a high-quality
product, and reduce the duration of testing, which is
spent on manual efforts.
3
The Classification Testing Tools
The software testing tools can be divided into the
following:
Unit testing tool
Automated testing tool
Cross-browser testing tool
Integration testing tool
Test management tool
Bug tracking tool
Mobile/android testing tool
Performance testing tool
GUI testing tool
Security testing tool
4
The Classification Testing Tools
Unit testing tool
This testing tool is used to help the programmers to
improve their code quality, and with the help of
these tools, they can reduce the time of code and the
overall cost of the software.
Automation testing tool
This type of tool is used to enhance the productivity
of the product and improve the accuracy. We can
reduce the time and cost of the application by
writing some test scripts in any programming
language.
5
The Classification Testing Tools
Cross-browser testing tool
This type of tool is used when we need to compare a
web application in the various web browser
platforms. It is an important part when we are
developing a project.
With the help of these tools, we will ensure the
consistent behaviour of the application in multiple
devices, browsers, and platforms.
Integration testing tool
This type of tool is used to test the interface between
modules and find the critical bugs that are happened
because of the different modules and ensuring that
all the modules are working as per the client
requirements. 6
The Classification Testing Tools
Test management tool
Test management tools are used to keep track of all
the testing activity, fast data analysis, manage
manual and automation test cases, various
environments, and plan and maintain manual testing
as well.
Bug tracking tool
The defect tracking tool is used to keep track of the
bug fixes and ensure the delivery of a quality
product. This tool can help us to find the bugs in the
testing stage so that we can get the defect-free data in
the production server. With the help of these tools,
the end-users can allow reporting the bugs and issues
directly on their applications.
7
The Classification Testing Tools
Mobile/android testing tool
We can use this type of tool when we are testing any
mobile application.
Some of the tools are open-source, and some of the
tools are licensed. Each tool has its functionality and
features.
Performance testing tool
Performance or Load testing tools are used to check the
load, stability, and scalability of the application.
When n-number of the users using the application at
the same time, and if the application gets crashed
because of the immense load, to get through this type
of issue, we need load testing tools.
8
The Classification Testing Tools
GUI testing tool
GUI testing tool is used to test the User interface of the
application because a proper GUI (graphical user
interface) is always useful to grab the user's attention.
These type of tools will help to find the loopholes in the
application's design and makes its better.
Security testing tool
The security testing tool is used to ensure the security of
the software and check for the security leakage.
If any security loophole is there, it could be fixed at the
early stage of the product.
We need this type of the tool when the software has
encoded the security code which is not accessible by the
unauthorized users.
9
Unit testing
Unit testing is a manual process, but now some of
the organization has automated the unit test with the
help of these tools.
By using unit testing tools, we can cover the
maximum coverage, performance, compatibility, and
integration testing.
All the unit testing tool is implemented as a plug-in
for the eclipse.
Unit testing tools are used by the developers to test
the source code of the application or to achieve the
source code of the application.
10
Continued…
Unit testing tools
Junit
NUnit
TestNG
Mockito
PHPUnit
11
Continued…
It is written in Java programing language
It is mainly used in the development of the test-driven
environment.
Junit offers the annotation, which helps us to find the test
method.
This tool helps us to enhance the efficiency of the developer,
which provides the consistency of the development code and
reduces the time of the debugging.
Feature of JUnit
It offers the assertions for testing expected results.
This tool can be structured in the test suites, which have the test
cases.
To run the test, it gives the test runners.
It will take less time to run the test cases.
12
Continued…
To perform unit testing, we need to create test cases.
The unit test case is a code which ensures that the program
logic works as expected.
The org.junit package contains many interfaces and classes
for junit testing such as Assert, Test, Before, After etc.
Annotations for Junit testing
The Junit 4.x framework is annotation based, so let's see the
annotations that can be used while writing the test cases.
@Test annotation specifies that method is the test method.
@Test(timeout=1000) annotation specifies that method will
be failed if it takes longer than 1000 milliseconds (1 second).
13
Continued…
@BeforeClass annotation specifies that method will be
invoked only once, before starting all the tests.
@Before annotation specifies that method will be
invoked before each test.
@After annotation specifies that method will be
invoked after each test.
@AfterClass annotation specifies that method will be
invoked only once, after finishing all the tests.
14
Continued…
Assert class
The org.junit.Assert class provides methods to assert the
program logic.
Methods of Assert class
The common methods of Assert class are as follows:
void assertEquals(boolean expected,boolean actual):
checks that two primitives/objects are equal. It is
overloaded.
void assertTrue(boolean condition): checks that a
condition is true.
void assertFalse(boolean condition): checks that a
condition is false.
void assertNull(Object obj): checks that object is null.
void assertNotNull(Object
15
obj): checks that object is not
Continued…
package com.javatpoint.logic;
public class Calculation {
16
Write the test case
The main testing code is written in the testFindMax() method. But
we can also perform some task before and after each test, as you
can see in the given program.
package com.javatpoint.testcase;
import static org.junit.Assert.*;
import com.javatpoint.logic.*;
import org.junit.Test;
public class TestLogic {
@Test
public void testFindMax(){
assertEquals(4,Calculation.findMax(new int[]{1,3,4,2}));
assertEquals(-1,Calculation.findMax(new int[]{-12,-1,-3,-4,-2}));
}
}
17
Understand The Automation Testing Approach
Automation is making a process automatic
eliminating the need for human intervention.
It is a self-controlling or self-moving process.
Automation Software offers automation wizards and
commands of its own in addition to providing a task
recording and re-play capabilities.
Using these programs you can record an IT or
business task.
18
Benefits of Automation
Fast
Reliable
Repeatable
Programmable
Reusable
Makes Regression
testing easy
Enables 24*78 Testing
Robust verification.
19
Automation Test Workflow
20
History of Selenium
In 2004 invented by Jason R. Huggins and team.
Original name is JavaScript Functional Tester [JSFT]
21
What is Selenium?
Selenium is a Functional Automation tool for Web
applications.
Selenium is an open source tool (No cost Involved in it).
Selenium supports the languages like HTML, Java, PHP,
Perl, Python, Ruby and C#.
It supports the browsers like IE, Mozilla Firefox, Safari,
Google Chrome and Opera.
It supports the operating systems like Windows, Linux
and Mac.
It is very flexible when compared to QTP and other
functional tools, because it supports multiple languages.
22
Components of Selenium
23
Selenium IDE
IDE stands for Integrated Development
Environment.
Which is used for Record and Play back the scripts.
It is an Add on for Mozilla Firefox, which means we
can download the Selenium IDE from Mozilla
Firefox and we can Record and Run the scripts in
Mozilla Firefox only.
Selenium IDE is accountable for user actions.
We can Run the Recorded scripts against other
browsers by using Selenium RC
24
Continued…
Advantages :
Very easy to install
No programming experience is required
Can export tests to Selenium RC and
webdriver usable formats
Disadvantage :
Available only in Firefox
Test Execution is slow compared to Selenium
RC and WebDriver
25
Selenium IDE – Why Choose
To learn about concepts on automated testing and
Selenium, including:
Selenese commands such as type, open, clickAnd Wait,
assert, verify, etc.
Locators such as id, name, xpath, css selector, etc.
Executing customized JavaScript code using runScript
Exporting test cases in various formats.
To create tests with little or no prior knowledge in
programming.
To create simple test cases and test suites that you can
export later to RC or WebDriver.
To test a web application against Firefox only
26
Selenium RC
RC stands for Remote Control.
It is a Server and launches the Browser.
It acts as a API and Library of Selenium.
We need to configure the Selenium RC with the supported
language, then we can automate the application.
Advantage
Cross browser and cross platform
Can perform looping and conditional operations
Can support data driven testing
Faster execution than IDE
Disadvantage
Installation is more complicated than IDE
Must have Programming knowledge
Needs selenium RC server to be running
Slower execution times than webdirver
27
Selenium WebDriver
The Web Driver proves itself to be better than both Selenium IDE
and
Selenium RC in many aspects. It implements a more modern and
stable approach in automating the browser's actions. Web Driver,
unlike Selenium RC, does not rely on JavaScript for automation. It
controls the browser by directly communicating to it.
The supported languages are the same as those in Selenium RC.
Java
C#
PHP
Python
Perl
Ruby
28
Continued…
Advantage
Simpler installation than Selenium RC
Communicates directly with browser
No need for a separate component such as RC
Faster execution time than IDE and RC
Disadvantage
Installation is more complicated than IDE
Requires Programming knowledge
Cannot readily support new browsers
29
Selenium Grid
Selenium Grid is used for launching the
multiple browsers with supported operating
system in parallel.
We can run the scripts on different browsers
in parallel.
It allows you to easily run multiple tests in
parallel, on multiple machines, in a
heterogeneous environment
30
Selenese
Selenium commands, often called selenese.
The set of these commands are nothing but
test script.
If you want to write test scripts for any
application, initially you need to integrate
Selenium with Java by using Eclipse. (check
the Integration doc).
After completion of the integration, First we
need to create the selenium object
31
Continued…
Generally we use the below selenium commands to
work on any application:
Start(): To launch the Browser.
Open(): To open the url.
Close(): To kill or close the Browser.
windowMaximize(): To maximize the window.
Type(): To enter some text into a text box.
Click(): To click on Button, Radio button and Link.
Select(): To select a value or label from combo box or
list box or Drop down.
32
Continued…
Check(): To check the check box.
selectPopUp(): To identify the pop up window.
selectWindow(): To identify the child window.
selectFrame(): To identify the frame.
getAlert(): To Click ok on alert box.
getConfirmation(): To click ok on confirmation
message.
chooseCancelOnNextConfirmation(): To click Cancel
on next displayed confirmation message.
chooseOkOnNextConfirmation(): To click Cancel on
next displayed confirmation message.
33
Selenium WebDriver
WebDriver is a tool for automating testing web
applications. It is popularly known as Selenium 2.0.
WebDriver interacts directly with the browser without
any intermediary, unlike Selenium RC that depends on a
server.
It is used in the following context:
Multi-browser testing including improved functionality
for browsers which is not well-supported by Selenium
RC (Selenium 1.0).
Handling multiple frames, multiple browser windows,
popups, and alerts.
Complex page navigation.
Advanced user navigation such as drag-and-drop.
AJAX-based UI elements.
34
WebDriver in Different Browsers
Google Chrome
Mozilla Firefox
MS Internet Explorer
Safari
Example
WebDriver driver;
System.setProperty("webdriver.chrome.driver", “<<Path of
chromedriver.exe>>");
driver = new ChromeDriver();
System.setProperty("webdriver.gecko.driver", “<<path of
geckodriver.exe>>");
driver = new FirefoxDriver();
System.setProperty(“webdriver.ie.driver ",“<<Path of
IEDriverServer.exe>>");
driver = new InternetExplorerDriver();
driver = new SafariDriver();
35
Continued…
• Locating elements in WebDriver is done by using
the findElement(By.locator()) method
36
Continued…
37
Accessing Different Objects in Application
Dropdown, Multi select
Text Fields Declare the drop-down
.sendKeys(“value”) element
.clear() Select elmDrp=new Select
(WebElement)
Radio button, Link elmDrp.selectByVisibleText
.click() (”text”)
Checkbox deselectByVisibleText()
.click() selectByIndex()
deselectByIndex()
.isSelected()
isMultiple()
deselectAll()
38
Switch Window
Switching Between Frames
driver.switchTo().frame(“FrameName”)
Switching Between Pop-up Windows
driver.switchTo().alert()
Get pop-up message
driver.switchTo().alert().getText()
Click on OK on pop-up
driver.switchTo().alert().accept()
39
Wait in WebDriver
Implicit wait
Used to set the default waiting time throughout the
program
driver.manage().timeouts().implicitlyWait(30,
TimeUnit.SECONDS);
Explicit wait
used to set the waiting time for a particular instance
only
WebDriverWait wait = new
WebDriverWait(driver,10);
wait.until(ExpectedConditions.visibilityOfElementLo
cated(By.name("userName")));
40
Verifications
Check object exist
driver.findElements(obj).size()
driver.findElement(obj).isDisplayed()
isEnabled()
isDisplayed()
isSelected()
elementToBeClickable()
frameToBeAvailableAndSwitchToIt()
41
WebTable
To get items from a table we can create object by table
xpath
To get value from different row and column create
dynamic object run time
String xpath = "//table[@width=\"270\"]/tbody/tr[" +
row + "]/td[" + col + "]";
driver.findElement(By.xpath(xpath)).getText();
Can create table xpath with some unique property
42
Example of Selenium WebDriver
• import org.openqa.selenium.By;
• import org.openqa.selenium.WebDriver;
• import org.openqa.selenium.WebElement;
• import org.openqa.selenium.chrome.ChromeDriver;
• import org.testng.Assert;
• import org.testng.annotations.Test;
• public class LoginAutomation {
• @Test
• public void login() {
• System.setProperty("webdriver.chrome.driver", "path of driver");
• WebDriver driver=new ChromeDriver();
• driver.manage().window().maximize();
• driver.get("https://www.browserstack.com/users/sign_in");
43
Continued…
• WebElementusername=driver.findElement(By.id("user_email_Login"));
• WebElement password=driver.findElement(By.id("user_password"));
• WebElement login=driver.findElement(By.name("commit"));
• username.sendKeys("[email protected]");
• password.sendKeys("your_password");
• login.click();
• String actualUrl="https://live.browserstack.com/dashboard";
• String expectedUrl= driver.getCurrentUrl();
• Assert.assertEquals(expectedUrl,actualUrl);
• }
• }
44
Thank you!
Questions?