0% found this document useful (0 votes)
13 views

Software Testing and Automation (Unit-5)

Unit-5

Uploaded by

Shyamala
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Software Testing and Automation (Unit-5)

Unit-5

Uploaded by

Shyamala
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

UNIT 5

TEST AUTOMATION AND TOOLS


DEFINITION – AUTOMATED SOFTWARE TESTING
AUTOMATED TESTING OF WEB APPLICATIONS – WHY ITS NEEDED
BENEFITS , CHALLENGES ,VARIOUS TOOLS
SELENIUM – 2 KEY COMPONENTS
LOCATING WEB ELEMENTS AND ACTIONS ON WEB ELEMENTS
WEB DRIVERS , ITS TYPES AND EVENTS
5.1 DEFINITION

• Automated Testing is a technique where the Tester writes scripts on their own and
uses suitable Software or Automation Tool to test the software. It allows for
executing repetitive tasks without the intervention of a Manual Tester.
• Automated testing is the application of software tools to automate a human-driven
manual process of reviewing and validating a software product. Most modern agile
and DevOps software projects now include automated testing from inception.
5.2 AUTOMATED TESTING OF WEB APPLICATIONS

• Use of software tools to execute test cases on web applications.


• Types of automated tests
• Functional testing
• Regression testing
• Non functional testing
• Performance testing
• Security testing
ADVANTAGES

• More reliable
• Improved quality and confidence
• Reduced cost
• Increased speed
CHALLENGES

• Initial investment in tools and frameworks


• Maintenance and updation
• Complexity – but it works efficiently if used right.
• Lack of expertise – difficult to get qualified testers
STEPS INVOLVED

• Planning of test cases, selecting right tools


• Development of automated tests
• Execute test cases
• Analyze ,report the results and recommendations.
VARIOUS AUTOMATION TOOLS

• Selenium
• TestNG
• Cypress
• Appium
• LoadRunner
• Testcafe
FACTORS TO CONSIDER FOR SELECTING RIGHT
AUTOMATION TOOL
• Application type and technology
• Programming language
• Learning curve
• Cost and licensing
• Team collaboration
• Testing requirements
3.3 SELENIUM

• Outstanding open-source ATT i.e. Automation Testing Tool.


• Widely used across 52k MNCs.
• Its test scripts can powerfully scale across variable computing environments
supported by multiple browsers
• Shows real-time compatibility with various frameworks and programming
languages
• Striking features supporting parallel test execution, thereby reducing test
execution times with its helpful and advanced automation scripts.
KEY COMPONENTS OF SELENIUM

• Selenium RC Remote Control – must know one programming language


• Selenium IDE –Record Run tool, Add on extension or plugin supports
chrome and firefox browsers.
• Selenium webdriver –supports multiple programming languages and
enhanced version of selenium RC
• Selenium Grid – concurrent execution of test cases across different
browsers, OS etc
SELENIUM IDE

• Shinya Kasatani developed the Selenium Integrated Development


Environment (IDE) in 2006.
• Conventionally, it is an easy-to-use interface that records the user
interactions to build automated test scripts. It is a Firefox or Chrome
plugin, generally used as a prototyping tool.
• It was mainly developed to speed up the creation of automation scripts.
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
•In this section of the Selenium automation testing tutorial, we will learn how to record a
test. Let’s first create a new test for a new project. Provide a name for your project, in
this example, we will call it demo_project. Before recording, we must specify a valid
URL. The recording begins once the browser navigates to this URL. Let’s navigate to
the Amazon login page.
• Save Your Work
• Next up, we’ll learn how to save your work in this Selenium Automation
Testing tutorial. To save everything you've just done in the IDE, click the
save icon in the top-right corner of the IDE. It will prompt you for a name
and a location of where to save the project. The result is a single file with
a.side extension.
• Playback
• In-browser: You can play tests back in the Selenium automation testing
IDE by selecting the test you wish to play and clicking on the Play button.
• For cross-browser playback, you can make use of the
command-line-runner.
3.4 WEB ELEMENTS

• Anything that is present on the web page is a WebElement such as text box,
button, input field, dropdown menu , links etc.
• WebElement represents an HTML element.
TYPES OF WEB ELEMENTS SELENIUM
1. Edit box
2. Link
3. Button
4. Image, image link, an image button
5. Text area
6. Checkbox
7. Radio button
8. Dropdown list
LOCATING WEB ELEMENTS USING VARIOUS
STRATEGIES
• Defined as the process of finding the HTML elements on a web page that it
wants to interact.
• Selenium provides methods and APIs to locate, interact and validate
behavior of these web elements during automated testing.
• Selenium provides functionalities that help in locating the element on a
web page. It makes use of element locators.
• Operations performed on the Selenium WebElements
• In order to access WebElements, we need to perform a set of operations starting with
browser actions until the operations are performed on frames.
• Operations performed on the browser
• Launch the browser
• Navigate to particular web page
• Close the current browser
• Close all browsers opened by WebDriver during execution
• Maximize browser
• Refresh the browser
• Operations on the web page
• Get page title
• Get page URL

• Operations on edit box


• Enter a value
• Get the value
• Clear the value

• Operations on link
• Click the link
• Return the link name
• Operations on text area
• Return or capture the messages from the web page

• Operations on checkbox
• Select the checkbox
• Unselect the checkbox

• Operations on radio button


• Select radio button
• Check if it displays the radio button

• Operations on drop down


• Select an item in the list
• Get the item count
• Locators are defined as an address that identifies a WebElement uniquely
within a web page.
• It is a command that tells Selenium IDE which GUI elements it needs to
operate, like – Text Box, Buttons, Check Boxes, etc. Using the right
locator ensures that the tests are faster, more reliable and has lower
maintenance over releases.
Types of element locators
In order to identify WebElements accurately and precisely, Selenium makes use of
different types of locators, namely:
•ID locator: The most popular way to identify web element is to use ID. ID’s are considered
as the safest and fastest locator option and should always be the first priority among multiple
locators.
•Name locator: This is also an effective way to locate an element which has a name
attribute. With this strategy, the first element with the value of the name attribute will be
returned. If no element has a matching name attribute, then
a NoSuchElementException will be raised.
▪ LinkText & ParialLinkText: You can identify the hyperlinks on a web
page using this linkText. It can be determined with the help of an anchor
tag (<a>). To create the hyperlinks on a web page, you can use the anchor
tags followed by the link text.
• CSS Selector
CSS is mainly used to provide style rules for the web pages and you can
use it for identifying one or more elements in the web page. The CSS
selector is always the best possible way to locate complex elements in
page.
• XPath: XPath is a language to query XML documents. XPath is an
important strategy to locate elements in selenium. It also consists of a path
expression along with some conditions
• WebDriver provides two methods to find the elements on the web page.
• findElement() – finds a single WebElement and returns it as a WebElement object.
• findElements() – finds elements in a particular location using locators
• Example to Locate WebElement in Selenium
• To start with the demo, we require certain prerequisites to work on WebElements in
Selenium.
• Java libraries
• IDE. We prefer working on Eclipse because it is more efficient when working on Java
projects
• In this demo, we’ll see how to automate one of the most famous e-commerce
website Amazon where we’ll understand the WebElement interface.
• First, we need to select a browser to perform actions. In this case, we will work on
Chrome so select the ChromeDriver browser and specify the path in which it is present
• Instantiate the ChromeDriver instance
• Get the URL of the web page
• Maximize the current web page
• Find the web element using the element locators like ID, name, class and so on
• Send keys to the particular location on the web page
• Click the search button
• Navigate to a new website
• Navigate back to the previous web page by using the operations
• Selenium WebDriver
• Developed by Simon Stewart in 2006, Selenium WebDriver was the first
cross-platform testing framework that could configure and control the
browsers on the OS level. It served as a programming interface to create
and run test cases.

You might also like