Software testing Unit V (1)
Software testing Unit V (1)
Functional Testing
It is used to ensure that the functionality specified as part of the software requirements works
deliberately from the end user’s perspective.
Functional testing is a day-to-day knowledge that the test process that uncovers the most bugs
lets the end-user explore the software.
It can automate the research process, mainly when working with remote participants.
User testing software aids you to connect with users and automatically gathers data without
any deliberation and then displays who hit their goals or where users struggled, allowing you to
2
build better products for happier customers, you can even call it automated end-user experience
testing. Automating it can save resources, reduce cost, get an overall test coverage, and have an
enhanced return of investment(ROI) for design.
It's a good idea to have others evaluate your work with fresh eyes, and this is especially true in
user experience and web design.Taken From Article, Guide to Usability Testing
Performance Testing
Security Testing
Automating web application security testing can help minimize human errors and also decrease
the cost factor. For automating security testing in a web application, we need massive test
coverage, the accuracy of test results, scheduled security tests,
Choosing appropriate tools and, in the end, to implement and iterate the process.
Software or hardware conducted on an entire, integrated system to assess the system's
compliance with its specified requirements.Taken From Article, System Testing Types, Best
Practices and Tools
What are the best tools for it?
1) Ketalon studio:
3) Selenium:
Selenium WebDriver is the most important component of Selenium Tool's Suite. The latest release
"Selenium 2.0" is integrated with WebDriver API which provides a simpler and more concise
programming interface.
The following image will give you a fair understanding of Selenium components and the Test
Automation Tools.
Selenium WebDriver performs much faster as compared to Selenium RC because it makes direct calls
to the web browsers. RC on the other hand needs an RC server to interact with the browser.
WebDriver has a built-in implementation of Firefox driver (Gecko Driver). For other browsers, you
need to plug-in their browser specific drivers to communicate and run the test. Most commonly used
WebDriver's include:
o Google Chrome Driver
o Internet Explorer Driver
5
o Opera Driver
o Safari Driver
oHTML Unit Driver (a special headless driver)
LOCATING WEB ELEMENTS:
Locators in Selenium are very important in the test automation of web applications. It helps
developers and testers locate and interact with the web elements on a web page to conduct
automated testing.
Using locators, it is easy to locate and identify particular HTML elements, including links,
dropdown menus, buttons, and text boxes. It is very important to understand locators while
utilizing Selenium to build strong, dependable, and maintainable automated tests.
Locators in Selenium are key to automated software testing, allowing automation tools to
interact with UI elements.
Types of locators include ID, name, class, tag name, link text, and partial link text locators,
chosen based on the test case's specific needs and the properties of the element located.
The efficient use of locators can significantly improve the speed and accuracy of test
automation, making it an essential aspect of modern software development.
In Selenium, actions on web elements typically involve interacting with web elements, such as
clicking buttons, entering text, dragging and dropping, hovering, and more. Selenium provides various
ways to perform these actions directly or through more complex chained actions. Here’s a breakdown
of commonly used Selenium actions for web elements.
Basic Actions
1. Clicking Elements:
python
Copy code
element = driver.find_element(By.ID, "example-id")
element.click()
3. Clearing Text:
python
Copy code
element = driver.find_element(By.NAME, "example-name")
element.clear()
Selenium's ActionChains class allows you to perform more complex actions, such as hovering,
double-clicking, right-clicking, and even drag-and-drop operations. First, you’ll need to import it:
python
Copy code
from selenium.webdriver.common.action_chains import ActionChains
2. Double-Clicking:
python
Copy code
element = driver.find_element(By.ID, "example-id")
action = ActionChains(driver)
action.double_click(element).perform()
6. Releasing a Click:
python
Copy code
action.release().perform()
Copy code
from selenium.webdriver.common.keys import Keys
Scrolling Actions
1. Scrolling to an Element:
python
Copy code
element = driver.find_element(By.ID, "example-id")
driver.execute_script("arguments[0].scrollIntoView();", element)
To ensure actions are performed on elements that are ready, you can use WebDriverWait:
python
Copy code
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
These actions are fundamental for building reliable, interactive tests with Seleni
DIFFERENT WEB DRIVERS
Drivers are required for different types of browsers. Selenium WebDriver refers to both the
language bindings and the implementations of the individual browser controlling code. This is
commonly referred to as just WebDriver.
Selenium WebDriver is a web framework that permits you to execute cross-browser tests. This
tool is used for automating web-based application testing to verify that it performs expectedly.
Selenium WebDriver also allows you to choose a programming language to create test scripts.
10. Apart from above list, you might have listen some name like:
WebDriverEventListener Interface
Predefined Methods used to implement the WebDriverEventListener Interface are enlisted below:
(i) void beforeChangeValueOf(WebElement arg0, WebDriver arg1,CharSequence[] arg2)
This method is triggered when we perform either the sendKeys() or clear() operation on the Web
Element. [For instance, driver.findElement(By.id(“Login”)).clear()], and is
triggered BEFORE performing the operation on the Web Element.
Parameters:
arg0= Web Element
arg1=driver
TestNG.xml file is an XML file which contains all the Test configuration and this XML file
can be used to run and organize our test.
The testng.xml file has the numerous uses as listed below
Right-click on the project folder & towards the bottom of the list, select TestNG and then
“Convert to TestNG.”
Click on Next
The next window that pops up will have the refactored source code, which would be applicable
after you click Finish.
A new addition to your project directory would be displayed named as testng.xml.
Double click on testng.xml to open the xml file
Method 2:
<suite name="Suite">
<test name="Test">
<classes>
<class name="testng.TestNGTestOne"/>
</classes>
TestNG XML file is for running parallel tests in a Selenium Grid, it is time to learn how to create a
TestNG XML file.
13
<classes>
<methods>
</methods>
</classes>
</test>
</suite>
package com.test.firstpackage;
import org.testng.annotations.Test;
14
@Test
public void firstTestCase()
{
System.out.println("First TestNG test in First Package");
}
@Test
public void secondTestCase()
{
System.out.println("Second TestNG test in First Package");
}
@Test
public void thirdTestCase()
{
System.out.println("Third TestNG test in First Package");
}
}
TEST REPORTS
Testing Reports are the default HTML reports which are generated once the test cases are executed
using TestNG. These reports help you to identify the information about test cases and the status of a
project. TestNG reports in Selenium have three methods passTest, failTest, and skipTest to check the
data about test cases.
15
Consider the scenario in where you are intentionally failing the test case i.e. DemoB class.
Then convert both the classes into testng.xml suite file and run it. Then the result will look like this. It
will show the failed test cases.
This is result for DemoB class:
In software testing, reports are essential to track the progress, quality, and outcomes of tests. Test
reports help teams understand what passed, failed, or needs further investigation, making them vital
for decision-making. Here’s an overview of the main types of test reports and how you can create
them.
d) Summary Reports
1. Header:
o Title: Name of the test report
o Date: Execution date
o Environment: Details about the environment (staging, production, etc.)
o Prepared by: Tester’s name or team
2. Summary of Execution:
o Total test cases
o Passed, failed, skipped test cases
o Key highlights and observations
4. Defects Summary:
o List of bugs, defect IDs, severity, and current status
5. Coverage Information:
o Coverage percentage and details on areas tested/not tested
Most frameworks have built-in reporting capabilities or plugins that can generate detailed reports.
JUnit and TestNG (Java): Use plugins like Allure or ExtentReports for detailed HTML or
XML reports.
java
Copy code
@AfterSuite
public void generateReport() {
// Code to integrate with reporting plugin
}
Pytest (Python): Pytest has built-in reporting, and you can use plugins like pytest-html or
pytest-allure:
bash
Copy code
pytest --html=report.html --self-contained-html
Using Continuous Integration Tools
Jenkins: Use plugins like JUnit or Allure to generate and visualize reports.
GitLab CI and CircleCI: Configure YAML files to store and share reports.
Using Custom Scripts
In some cases, custom scripts (Python, JavaScript) can parse results and create custom reports in
HTML, JSON, or CSV format.
Allure Report: A popular tool for generating HTML reports across multiple languages and
frameworks.
ExtentReports: Offers beautiful HTML reports with dashboards, logs, and screenshots.
ReportPortal: For real-time reporting, integrations with CI/CD pipelines, and log aggregation.
TestRail: Comprehensive test case management and reporting tool for large teams.
Automate Reports: Use automated scripts or CI/CD tools to generate reports after every test
run.
Use Visual Elements: Include charts and graphs to make the reports easier to interpret.
Include Screenshots for Failures: Screenshots for failed tests help with debugging.
Summarize for Different Audiences: Have a summary at the top for stakeholders and detailed
sections for technical teams.
Highlight Key Defects and Risks: Identify the most critical issues, their impact, and any
potential risks.
18
Creating informative test reports helps streamline testing and debugging, making it easier for teams to
address issues and ensure quality in software development.