1. Copyright 2015 IT Professional Academy 1
Automation (Selenium)
Testing Course
WELCOME
2. Copyright 2015 IT Professional Academy 2
About IT Professional Academy
•Team of Highly Skilled Trainer with work Exp of 7+Y.
•Expertise in areas like Software Testing, Big Data,
Linux-Unix, SAP BI as well as Software Development.
•Provides both Classroom and Online Classes.
•Training centers across multiple cities.
•Provides Job Assistance, Interview preparation, Mock
Interviews, Resume Preparation.
4. Copyright 2015 IT Professional Academy 4
About Trainer:
Exp: 7+ Y in Automation Testing
Technical Expertise:
Selenium, QTP, Mobile Automation
Batch Intro.
5. Copyright 2015 IT Professional Academy 5
Demo Agenda
•Course Content
•Introduction to Software Testing
•Introduction to Automation Testing
•Introduction to Selenium World
•Introduction to HTML
•Introduction to Objects and Methods.
•Introduction to Selenium IDE
•Record and Play Back in Selenium IDE
6. Copyright 2015 IT Professional Academy 6
Course Content
•Introduction to Automation Testing
•Introduction to Selenium
•Selenium Components
•Configuration Of IDE and Dev Scripts
•Introduction to Eclipse and Junit
•Selenium Web Driver
•ValidationsAssertions
•Advance Interactions
•Framework Development
•Data Driven Testing
•TestNG Framework
•Selenium Grid
http://www.itprofessionalacademy.in/selenium.php
7. Copyright 2015 IT Professional Academy 7
Batch Expectations
What are your Expectations with
this course?
8. Copyright 2015 IT Professional Academy 8
Introduction To Software Testing
•Purpose of Software Testing: To get Quality
Product with out exceeding the set Cost.
Live Example: Bank Lost $10000k in a month
due to a defect.
•Methodologies in Testing: Water fall Vs Agile
•Software testing Life Cycle.
9. Copyright 2015 IT Professional Academy 9
Software Testing: Water Fall Model
12. Copyright 2015 IT Professional Academy 12
Testing Pyramid: Agile
•As testing is mostly done at the bottom,
Developer and Tester should Speak the Same
language.
•Ability of the tool for integration with the
Unit tests.
•And Selenium has that ability.
•Minimum at the top, most at the bottom.
Selenium works well with the approach.
13. Copyright 2015 IT Professional Academy 13
Introduction To Automation Testing
“Automation is the use of tools and strategies
that reduce human involvement or
interaction in repetitive or redundant tasks.”
14. Copyright 2015 IT Professional Academy 14
Need for Automation Testing?
Bottom Line:
“So that machine works while you sleep so
as to save
TIME
&
MONEY.
Budget is the Driving Factor for all automation
efforts.
15. Copyright 2015 IT Professional Academy 15
Need for Automation Testing?
ROI Example:
ROI = Benefit/Cost
Simple Rule: If Number of Automation
Tester is more than Number of Manual
Tester then ROI is not as Achieved.
17. Copyright 2015 IT Professional Academy 17
Before you Automate..
Ask two questions:
1. Shall you Automate?
Should get some value out of it.
“Automating Flow which will only be used once should not be
automated. Having said that, automating a flow which will be
used only once but is important and not possible manually;
should be automated.”
2. Can you Automate?
Check Automation feasibility.
“Before committing, always check if flow or AUT is feasible to
automate. Do not false commit.”
19. Copyright 2015 IT Professional Academy 19
Advantages & Disadvantages of
Automation Testing
Advantages Disadvantages
Saves Time High Investment in Tool and training
Cost Reduction Test Coverage
Reliable: Eliminating human error High man power requirement for test
preparations.
Reusable
Better Quality Software
20. Copyright 2015 IT Professional Academy 20
Criteria For Automation Test Tool
Scope
Ease of Integration
Compatibility
Performance
Types of tests
Maintainability
Affordability
21. Copyright 2015 IT Professional Academy 21
QTP Vs Selenium-1
QTP: It is commercial tool and hence it requires a license is expensive
Selenium: Its an open source tool hence it does not require license and
is free
QTP: It is used for testing client-server applications. It can test web-
based as well as desktop applications
Selenium: Using Selenium only web applications can be tested
QTP: QTP tests can only be developed in QTP IDE
Selenium: Selenium has the option of using wide range of IDEs like
Visual Studio, Eclipse, Netbeans
QTP: HP UFT only supports VB script
Selenium: Selenium supports JAVA, .NET, Ruby, Perl, PHP, and many
other programming languages
22. Copyright 2015 IT Professional Academy 22
QTP Vs Selenium-2
QTP: HP UFT comes with built in object repository. Object repository
development and maintenance is quite easy in HP ALM
Selenium: Selenium dose not have such built in object repository, but
object can be managed by using UI element user extension
QTP: HP UFT integrates with test management tool like HP Quality
Center
Selenium: There is no such tool that integrates with Selenium
QTP: All types of dialog box is supported by it
Selenium: It supports dialog box partially
QTP: It supports different environments like SAP, Oracle, .NET but
user need to purchase add-on license for them
Selenium: It supports addition of plug-ins to include features that are
not provided by core Selenium
23. Copyright 2015 IT Professional Academy 23
QTP Vs Selenium-3
QTP: Automation testing is expensive due to licensing cost
Selenium: Web automation testing with Selenium incurs less cost
QTP: HP QTP offers very good technical support
Selenium: It has no official support, since it is an open source
QTP: HP QTP supports only VBScript . Hence Object Oriented Approach
to Test Automation becomes challenging
Selenium: Selenium supports mature Object Oriented Language like
Java
QTP: HP QTP is more user friendly and scripts are developed quickly.
Selenium: It is a low level tool with less functionality. Script requires
more time to develop and maintain
QTP: Backward compatibility is powerful. Latest version of HP ALM
supports code that was developed 5 years back
Selenium: With new Selenium release the API changes. So Test Scripts
need to be updated
24. Copyright 2015 IT Professional Academy 24
QTP Vs Selenium-4
In Short it is similar to Buying a Laptop
QTP: Laptop with Windows 10 and useful Applications installed.
Every thing up and Running.
Selenium: Laptop Case + Hard Disk+ Ram+ Linux CD + useful
Applications CD. But Every thing for Free and Highly
customizable Set Up.
25. Copyright 2015 IT Professional Academy 25
Introduction to Selenium
Selenium overview
Selenium Landscape
Selenium Components
Differences between Selenium and QTP
Modern Day Browsers
Maintainability
Affordability
26. Copyright 2015 IT Professional Academy 26
Introduction to Selenium
Selenium automates browsers. That’s it. What you do with that is entirely up
to you
Primarily it is for automating web applications for testing purposes, but is
certainly not limited to just that.
Selenium has the support of some of the largest browser vendors who have
taken steps to make Selenium a native part of their browser.
It is also the core technology in countless other browser automation tools,
APIs and frameworks
Selenium provides an easy to use record and playback IDE in addition to
client API which Unleash the full power of an Object oriented automation
framework.
Selenium is an open source framework which cost nothing.
Selenium has full integration with commonly used IDEs like Eclipse etc.
29. Copyright 2015 IT Professional Academy 29
Selenium Components
•Selenium IDE: Mozilla Platform
•Selenium 2/ Web Driver: Java Platform
•Selenium Grid: Java Platform
•Selenium RC: Part of Selenium 2/Web Driver
30. Copyright 2015 IT Professional Academy 30
HTML Basics
Types of Control:
1. Text Elements
2. Text Box
3. Links
4. Table
5. Radio Group
6. Select List
7. Drop down
8. Check Box
9. Buttons
10.Hovers
11.Tooltips
31. Copyright 2015 IT Professional Academy 31
Object and Methods
Every thing is an Object.
All Objects has properties and methods/functions.
I am an Object:
Properties:
1. Name: Akash
2. Age: 34
3. DNA: ATCG
4. Weight: 80KG
And many more..
Actions I can
Do
1. Type(what to
type)
2. Dance(which
dance)
3. Sing(which
song)
And many more…
32. Copyright 2015 IT Professional Academy 32
Object and Methods
All Objects has Parent.
I am an Object:
Properties:
1. Name: Akash
2. Age: 34
3. DNA: ATCG
4. Weight: 80KG
And many more..
Actions I can
Do
1. Type(what to
type)
2. Dance(which
dance)
3. Sing(which
song)
And many more…
I am an Object:
Properties:
1. Name: Akash_Dad
2. Age: 60
3. DNA: ATCG_1
4. Weight: 75KG
And many more..
Actions I can
Do
1. Read(what to
type)
And many more…
33. Copyright 2015 IT Professional Academy 33
Object and Methods
<input id="gs_htif0" class="gsfi" disabled="" autocomplete="off" aria-
hidden="true" style="border: medium none; padding: 0px; margin: 0px;
height: auto; width: 100%; position: absolute; z-index: 1; background-color:
transparent; color: silver; transition: all 0.218s ease 0s; opacity: 0; text-align:
left; left: 0px;" dir="ltr" kl_virtual_keyboard_secure_input="on">
I am an Object:
Properties:
1. id: “gs_htifo”
2. class: “gsfi”
3. background-color:
“transparent”
and many more…
Actions I can Do
1. Type(Selenium)
2. Click
and many more..
Google
Input Box
34. Copyright 2015 IT Professional Academy 34
Target-Command-Value-Sync-
Verify
All interactions are the combination of :
1. Target
2. Command
3. Value
4. Sync
5. Verify
Analogy: “Paint- This Wall- With Red
Color-wait for it to Dry-Verify
35. Copyright 2015 IT Professional Academy 35
Selenium IDE
•The Selenium-IDE is the tool you use to
develop your Selenium test cases.
•Easy to use Firfox (only) plug in
•Record and Playback capabilities
•Context menu for UI Elements Selection
•Selenese Command reference
•Not only a time-saver, but also an excellent way
of learning Selenium Script syntax.
•Free and open source.
•Only for R&D; not a full fledged automation
FW.
37. Copyright 2015 IT Professional Academy 37
Selenium IDE
All step are the combination of :
1. Command
2. Target
3. Value
Analogy: “Paint- This Wall- With Red Color
38. Copyright 2015 IT Professional Academy 38
Selenium IDE
3 Types of Commands:
1. Actions: Commands that directly
interacts with page elements.
2. Assessors: Store values to a variable.
3. Assertions: Verify if a certain command
is met.
39. Copyright 2015 IT Professional Academy 39
Selenium IDE
Examples:
1. Actions: Click, Type
2. Assessors: storeTitle, store
3. Assertions: assert, verify, waitForTitle
40. Copyright 2015 IT Professional Academy 40
Selenium IDE
How to Identify Locators:
There are multiple ways to identify an
Object or Target or Locator:
By id
By name
By XPATH
By Link Text
By CSS
By DOM
41. Copyright 2015 IT Professional Academy 41
Selenium IDE
HTML Representation:
<input id="payee.name" class="input" type="text" v
alue="" name="payee.name" kl_virtual_keyboard_s
ecure_input="on">Enter your Name</>
•By id = id="payee.name"
•By name = name="payee.name"
•By XPATH = //input[@id = ‘payee.name]
Or
//input[@id = ‘payee.name’ and containsText() =
‘Enter your Name’]
42. Copyright 2015 IT Professional Academy 42
Selenium IDE
Example By id, name, xpath:
Google Search Box: Locate by
id= gs_htif0;
name=q;
xapth=//div[@id='gs_lc0']/input
43. Copyright 2015 IT Professional Academy 43
Selenium IDE
Example:
Record Script
Demo Site:
http://parabank.parasoft.com/parabank/index.htm
Script1: ValidateLoginFunctionality
Script2: CheckBillPaymentFunctionality
44. Copyright 2015 IT Professional Academy 44
Selenium DAY 2
Hands On IDE
45. Copyright 2015 IT Professional Academy 45
Verify And Assert
Verify will continue execution.
Assert will halt execution in case of failues.
46. Copyright 2015 IT Professional Academy 46
Other Imp Commands
•type
•typeAndWait
•assertTextPresent
•assertTextNotPresent
•pause
•refresh
•waitForPageToLoad
•storeLocation
•storeTitle
•Check, uncheck
•mouseOver, mouseOut, mouseOverAndWait
•storeSelectedIndex, storeSelectedIndexes
•assignId, captureEntirePageScreenshot
•storeSelectOptions, storeValue
•Break,goBack
•verifyAlert, assertAlert.
47. Copyright 2015 IT Professional Academy 47
Other Imp Commands
Assert: Execution will Verify, But stops if verification
failed.
48. Copyright 2015 IT Professional Academy 48
StoreText and StoreTextPresent
"storeText" command is useful to store text value of page element in to variable for
future use
"storeTextPresent" command is not for storing value of any target element, but it
is useful to verify that
specified target text is available on page or not.
49. Copyright 2015 IT Professional Academy 49
Store and Echo
Store: Is used to Store value in a variable.
Once stored can be used across multiple tests in Run Session.
Echo: To Print the value.
50. Copyright 2015 IT Professional Academy 50
Clip Board Format
<tr> <td>open</td>
<td>/parabank/index.htm</td>
<td></td></tr><tr>
<td>type</td>
<td>name=username</td>
<td>john</td></tr><tr>
<td>type</td>
<td>name=password</td>
<td>demo</td></tr><tr>
<td>clickAndWait</td>
<td>css=input.button</td>
<td></td></tr><tr>
<td>storeText</td>
<td>//table[@id='accountTable'
]/tbody/tr[12]/td[2]/b</td>
<td>totalAmmount</td></tr><
tr> <td>echo</td>
<td>${totalAmmount}</td>
<td></td></tr>
After copying the Rows in the
IDE.
51. Copyright 2015 IT Professional Academy 51
Clip Board Format
driver.get(baseUrl +
"/parabank/index.htm");
driver.findElement(By.name("username")
).clear();
driver.findElement(By.name("username")
).sendKeys("john");
driver.findElement(By.name("password")
).clear();
driver.findElement(By.name("password")
).sendKeys("demo");
driver.findElement(By.cssSelector("input.
button")).click(); String totalAmmount
=
driver.findElement(By.xpath("//table[@i
d='accountTable']/tbody/tr[12]/td[2]/b"))
.getText();
System.out.println(totalAmmount);
After copying the Rows in the
IDE.
52. Copyright 2015 IT Professional Academy 52
Convert to Junit Web Driver Code
Convert to JUnitWeb Driver Code
53. Copyright 2015 IT Professional Academy 53
Selenium DAY 1 Ends.
Thank you.
Notas do Editor
http://www.itprofessionalacademy.in/selenium.php
If green line is not getting constant, ROI will never be achieved.
But this is water fall. Old Approach.
Minimum at the top, most at the bottom. Selenium works well with the approach.
Minimum at the top, most at the bottom. Selenium works well with the approach.