AutomationTest Part1
AutomationTest Part1
Software Automation
Testing Secrets Revealed
EDUCREATION PUBLISHING
RZ 94, Sector - 6, Dwarka, New Delhi - 110075
Shubham Vihar, Mangla, Bilaspur, Chhattisgarh - 495001
Website: www.educreation.in
________________________________________________________________
© Copyright, Authors
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted, in any form by any means, electronic, mechanical, magnetic, optical, chemical,
manual, photocopying, recording or otherwise, without the prior written consent of its writer.
ISBN: 978-1-5457-0825-5
Price: INR 1015.00
The opinions/ contents expressed in this book are solely of the authors and do not
represent the opinions/ standings/ thoughts of Educreation or the Editors .The book is
released by using the services of self-publishing house.
Printed in India
ii
Although the author and publisher have made every effort to ensure that the information in
this book was correct at press time, the author and publisher do not assume and hereby
disclaim any liability to any party for any loss, damage, or disruption caused by errors or
omissions, whether such errors or omissions result from negligence, accident, or any other
cause.
This book is not intended as a substitute for the official guides provided by tools such as
selenium, uft and ranorex etc. The reader should regularly consult official pages of
automation tools in matters relating to features and functionalities and particularly with
respect to any code examples that may require to build automation frameworks.
The information in this book is meant to supplement, not replace, proper testing tools. Like
any tools involving software engineering, (testing tools) poses regular changes and
releases. The authors and publisher advise readers to take full responsibility for upgrading
their knowledge by visiting official web pages of automation tools. Before practicing the
skills described in this book, be sure that your testing tool is latest and downloaded from
official websites of software testing tools
Credits:
iii
Narayanan Palani
EDUCREATION PUBLISHING
(Since 2011)
www.educreation.in
iv
vi
ix
xi
xii
xiii
Where the readers can refer the code examples since there are
very less or few code examples in the book?
Since the target readers are primarily from graduation, freshers,
Non-IT background and are novice to the software engineering
roles, most of the scripts are accessed from GitHub and the details
xiv
xv
"Very much helpful for those who are new to automation testing,
Detailed explanation with perfect practical coverage. What else
you need to jump-start in the globe of software automation!"
xvi
Raman Sharda
"This will be definitely helpful for all the current automation test
engineers and upcoming automation test engineers. All the best!"
xvii
xviii
Neethu Joseph
"Great book! This book is for people who want to know in depth of
Selenium Webdriver concepts. And also the topics have been
explained in detail which will be very useful for the people who
want to start a new career or for cracking interviews. This is a must
buy!"
Dinesh Balaji,
Test Automation Specialist, USBANK
Rahul Bhat
Rohan Vakharia
xix
Sriharsha Karanth
"Keep up the good work, as always you do. It will help everyone to
know when exactly automation testing can be used and how useful
it will be by saving time …."
"I know you are dynamic and interesting blog writer. Nice to see
you as a good author. You are brilliant person and we are
expecting soon to read the revealing secrets of the Software
Automation Testing … your abstract tells – sample projects to
download and practice on specific chapters! This would be helpful
for advanced and all levels of testing professionals."
Vijeyasekaran Kbd
xx
"This book is really helpful for people who want to grow in the
testing domain. Everything is explained in very easy language. A
book highly recommended for testers."
"This book will surely encompass all corners of testing a to zee ....
It will be beneficial for all testers irrespective of what profile they
are into … people looking for transitioning from manual to
automation will get the most …."
Shubham Joshi
"It will be beneficial for all testers irrespective of what profile they
are into … people looking for transitioning from manual to
automation will get the most …."
xxi
Krishnamurthy Chinnasamy,
Finance Manager, Britannia Industries Limited
Kothandan Sivalingam,
Quality Analyst, Dupont sustainable solutions L&D
Kamalbharathi Murugesan,
South Plainfield, New Jersey
Sohag Satpati
xxii
NARAYANAN PALANI
MS (SOFTWARE ENGINEERING) – BITSPilani
EXEC MBA from K.J. Somaiya Institute
of Management and Studies, Mumbai
EXPERIENCE SUMMARY
Nine years of strong QA experience in automation, functional,
performance and penetration testing
Exclusive agile test projects experience using Selenium,
Cucumber, TestNG, HP UFT and Ranorex
Strong on test process, programming such as Java, JavaScript,
VBScript, C#, Ruby, Python, Gherkin
Proven test automation capabilities in TDD and BDD – SpecFlow
for integration and unit testing
Formulated high-quality master test plan, test strategy, automation
PoC, estimates and test scripts
Efficaciously implemented SDLC, ISO and CMMI standards and
worked on Agile model-based projects
Delivered high-quality test results and defects using HP QC, Rally
and other test management tools
Experienced investment banking, trading and FX projects using
Murex, Intelligent FX and Summit
Directed functional, automation, performance and support
members to deliver high-quality results
xxiv
BACKGROUND
Narayanan Palani is endorsed as exceptional talent within digital
technology by Tech City UK. Being in a leading position of proven
and renowned software testing industry, Narayanan Palani
volunteered to share his technical knowledge through his best-
selling book series “Software Automation Testing Secrets
Revealed” which ranks top amongst the books on computer
science across APAC, USA and UK. His well-designed GitHub
open-source testing projects are accessed worldwide profusely and
have been assisting job seekers to bag junior testing jobs
successfully.
Being a leading test specialist and, at the same time, holding six
awards, fifteen international certifications, eight published research
papers and four books selling worldwide, he proceeded further to
innovate and implement cutting-edge technologies as part of his
recent roles. His IBM professional certificate profile i is viewed
worldwide, and newcomers are being inspired to take interest in
xxv
Linkedin Profile:
https://www.linkedin.com/in/narayananpalani/
xxvi
Ponsailapathy Viswanathan
Director-Delivery, Virtusa Polaris
Linkedin Profile:
https://www.linkedin.com/in/ponsailapathi-viswanathan-224a755/
xxvii
xxviii
Happy reading!
Ponsailapathy Viswanathan, Director-Delivery, VirtusaPolaris
xxix
xxx
Dos:
- Minutely focus your attention for 25 minutes without being
interrupted on any chapter.
xxxi
Don‟ts:
- Never force yourself to complete the book overnight or within
a week.
- Never plunge yourself into various programming languages
until automation framework has been developed in that
language.
- The task of reading the chapter and practicing the scripts
should not be performed simultaneously; a comprehensive
reading is must for a good conceptual understanding of the
subject, so the reading should not be a futile attempt;
„knowing‟ and „doing‟ are two different words.
- In case of meeting an unknown programming language in the
course of reading, practicing Java programs using „Java
BlackBook by Steven Holzner‟ is advised, but practicing
scripts in Eclipse or any IDE, while learning those
fundamentals, is strictly prohibited, as command prompt gives
quick learning in Java fundamentals (to analyze errors) rather
than IDEs which help in building the scripts (whereas Eclipse
can be used for Selenium-based learnings).
xxxii
xxxiii
xxxv
xxxvi
Introduction
As an exclusive specialized industry, software testing is growing
rapidly into automation, and the need of development experience
and tools knowledge is enormous to sustain in testing profession!
Tool-based testers are migrated to core automation testers over a
period of time with various tool experiences. The agile-based
projects brought the need for testers with strong development
background; hence, automation testers are migrated to 'developer-
in-test' roles to categories as a test specialist who is good at coding
background.
This book brings the essence of automation basics in different
topics varied from Selenium Webdriver to Excel VBA Test
Automation – so that the target audience can be benefited with
knowledge across the automation possibilities.
Definition
Set of assumptions, concepts, methods and workflows that
constitute a work platform and best practice that provide complete
support for automated automation framework testing and
maintenance.
This includes script organization, documentation, coding standards
&instructions, version control and unit test of the test scripts.
Key SFERMS Benefits – stable, flexible, extensible, reusable,
maintainable, scalable.
Usability
Automation framework usability can be described as how
effectively new test analysts/SME (Subject Matter Expert) can use,
learn or control the system. Some questionswhich are tobe asked to
yourself to determine usability might be as follows:
Best practice:
It is always a best practice to use an exclusive usability
5
Maintainability (flexibility/testability)
The definition of maintainability implies how brittle the code is to
change. As a result, I tie the terms flexibility and testability into the
overall maintainability of a project.
Best practice:
Automation scripts, functional library, other test scripts can be
externally controlled with different files which can be easy to
maintain file model since any update to the functional library in
future will affect specific files and rest of the framework remains
reusable!
Scalability
Scalability is the ability for your program to gracefully meet the
demand of stress caused by increased usage. In a nutshell, ensuring
your program doesn‟t slow or bust while pounded by more users
than you originally anticipated.
Extensibility
Are there points in the system where changes can be made with (or
without) program changes?
Security
The measure of system‟s ability is to resist unauthorized attempts
at usage or behavior modification, while still providing service to
legitimate users.
Portability
Portability is known to be the ability for your application to run on
numerous platforms. This can include actual application hosting,
viewing or data portability.
10
11
Selenium
Industry-wide best practice in test automation is to look for the
possibility of Selenium implementation in web-based testing
projects. Selenium has been evolved over a period of time since
2004, and it is available in four different types at the moment in
2015: Selenium IDE, Selenium Core, Selenium RC and Selenium
Grid. Selenium IDE (integrated development environment) is
available as an add-in for Firefox. Selenium Grid is used for NFT
(non-functional tests) like performance tests and concurrent tests.
Selenium Webdriver is widely used across the platforms as an
open-source test automation tool, and organizations build
automation framework on top of Selenium to make use of the tool
for testing projects.
Selenium 3.0 released on 13 Oct 2016 as per the updates at:
https://seleniumhq.wordpress.com/2016/10/13/selenium-3-0-out-
now/
Future
2004 2011 13Oct „16
release*
Selenium
Webdriver,Sele
Selenium Selenium
nium Selenium
IDE,Selenium Webdriver,Sel
Tools
IDE,Selenium W3C,Appiu
Core,Selenium enium
RC,Selenium m[for
RC,Selenium IDE,Appium[f
Core,Selenium mobile]
Server or mobile]
Server,Appium[
for mobile]
Webdriver
W3C
Advantages
12
Internationall
Firefox is W3C compliant
y agreed
connected with webdriver
Table-based standards are
the help of server: gecko
runner followed and
Firefox driver is used
gecko driver
extensions for Firefox
will be used
Internet
Selenium
Explorer's COM
Webdriver
HTML Table- object collection Selenium Core
may be
Selenium IDE used to removed
planned to be
communicate for
removed
tests
Safari
Chrome,Opera
extended to
extended to used
Three columns used as part
as part of
of webdriver
webdriver tests
tests
Selenium Introduced Jason Improved
Coredesigned by Wire Protocol Jason Wire
Jason for time representing Protocol
and expenses commands for targeted in
system Firefox driver Selenium 4
Since there were Selenium 5:
defects from
Target to
Internet
enable html5
Explorer,Firefox,
Selenium Core features,user
Opera for the
project integrated facing
Javascript
with webdriver APIs,friendly
application (time
project; hence, it locators,more
and expenses
has become focus of
system), he
Selenium webdriver
decided to run
Webdriver API towards
the tests in
mobile and
javascript and
drive the improved
application protocol
Incredibly
Disadvantages
Challenge-not
difficult to
possible to
manage table-
analyze source
based scripting
code of IE and
hence Selenium
other browsers
RC introduced
13
Selenium RC
scripts written in
multiple
languages and
Every browser
communicate to
follows different
Selenium Server,
wire protocol-
and this server
challenge for
has internal
webdriver
communication(c
ore protocol) to
Selenium Core
javascripts
Browsers have
Scripts running
become more
in javascript
complicated in
sandbox is a real
every version
challenge hence
hence Selenium
integrated with
decided to use
webdriver in
W3C for next
next version(in
version(in
Selenium2.0)
Selenium 3.0)
Selenium
Webdriver:Guar
anteed [but no
plans to use from
Selenium 4.0
onwards]*as per
the update from
Selenium
Simon on Sept'16
Webdriver:
Selenium IDE:
Limited [there
Guaranteed
Selenium are plans to
Selenium RC:
Life span
14
on Sept2016]
This table given above is derived on the basis of the inputs from
[1] Simon Stewart (2016 May 26),Selenium 3 0 Retrieved from
https://www.youtube.com/watch?v=gS4ZqLpA9r4
[2] Simon Stewart (2016 September 14),Learn Using Selenium 3
0Retrieved from https://www.youtube.com/watch?v=bistojJPR98
[3] W3C (2016 September 14),World Wide Web Consortium from
https://www.w3.org/
[4] SeleniumHQ(2016 September 14),Selenium from
https://www.seleniumHQ.org/
[5]Simon Stewart (2017September 6),Selenium 3 0 Retrieved from
https://www.eventbrite.co.uk/e/asos-qa-meetup-the-future-of-
selenium-by-simon-stewart-tickets-36864574936
15
Reference:
https://www.indeed.com/jobtrends/q-selenium-q-qtp.html
16
17
18
19
Types:
ID (Unique Locator):
Example:driver.findelement(By.id“textbox”));
Class
Name
Value
Text (Link text, Partial Link text)
XPATH (Relative X path)
CSS (Fastest Locator)
DOM
If none of the above works for you at times, use qa-selector as
discussed in your script across!
so it will be like,
driver.findelement(By.qa-selector(“textbox”));
20
21
Golden Rule 1:
Return on investment is always expected post 6 testing cycles!
Golden Rule 2:
It is not possible or worth to target 100% automation.
Golden Rule 3:
Once developed, automated scripts are not life proof (they have to
be maintained)!
Golden Rule 4:
If automation framework is not documented in detail, it is going to
be doomed in short time (no matter how strong the tool is!).
22
24
Feature file
Feature: Proof of concept of the cucumber framework
25
Step definitions
Each feature file,such as Given,When and Then, contains a step
definition which is as follows:
package cucumber.features;
import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
26
Cucumber runner
This component aids in running the associated feature file with its
step definition:
package cucumber;
import org.junit.runner.RunWith;
import cucumber.api.junit.*;
@Runwith(Cucumber.class)
@Cucumber.Option(
format = {"pretty,"json:target/cucumber.json"}
features = {"src/cucumber/"}
)
public class CucumberRunner {
}
27
28
Code:
package cucumber.features;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
//import org.openqa.selenium.android.AndroidDriver;
import org.openqa.selenium.chrome.ChromeDriver;
//import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.interactions.Actions;
//import org.openqa.selenium.iphone.IPhoneDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
//import org.openqa.selenium.safari.SafariDriver;
import java.util.concurrent.TimeUnit;
//import com.sun.jna.platform.FileUtils;
//import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
29
import cucumber.api.java.en.When;
//import cucumber.api.java.en.And;
//import cucumber.runtime.PendingException;
public class bbcradio {
public WebDriver driver;
@Before
public void setUp() {
System.out.println("*******************");
System.out.println("launching Chrome browser");
//System.setProperty("webdriver.ie.driver",
"E://AutomationProject//Training//LandroverTestProject//Browser
Drivers//IEDriverServer.exe");
System.setProperty("webdriver.chrome.driver",
"E:/AutomationProject/TrainingBBCRadioTestProject/BrowserDri
vers/ChromeDriver.exe");
}
31
Reference: https://www.nuget.org/packages/Selenium.WebDriver
Step4:Feature file
Right click on the project, select Add Item and choose SpecFlow
Feature File and Add to open the new feature file:
It would have been added, and .cs file would have been associated
by itself:
33
@RegressionTests
Scenario: average INR exchange rate of banks in London
Given I have opened the ABC Accounts page
And I have grabbed average "INR" rate in Exchange Rate section
Then I set "INR" currency in ABC Banks Today Exchange rates
section
When I compare calculated and rate along with fee values the
result should be correct
34
{
ScenarioContext.Current.Pending();
}
[When(@"I compare calculated and rate along with fee values the
result should be correct")]
public void
WhenICompareCalculatedAndRateAlongWithFeeValuesTheResul
tShouldBeCorrect()
{
ScenarioContext.Current.Pending();
}
Another example:
Develop the feature file with scenarios in Gherkin format then save
it as a .feature file.
*Refer Gherkin/SpecFlow sections
Example:
35
@RegressionTests
Scenario: average USD exchange rate of banks in London
Given I have opened the ABC Finance page
And I have grabbed average "USD" rate in Average Rate section
Then I set "USD" currency in ABC Banks rates section
When I compare calculated and grabbed values the result should be
equal to "4" decimal
37
38
ReportUnit
This tool helps in developing an html-based report out of xml
report of NUnit.
Download URL:http://reportunit.relevantcodes.com/
Once the tool has been downloaded, run the tool from command
line with the help of following syntax:
reportunit [input-folder-path] [output-folder-path]
Assuming the xml files of test results are stored at C drive's result
folder, you require the ReportUnit reports at reports folder; this can
be performed following steps given below:
1. Install Reportunit
2. Go to command line where Reportunit is placed
3. Enter the commands:
reportunit "C:\Results" "C:\Reports"
The abovementioned steps enable to get the html-based reports
within the folder reports-which can be shared with the stakeholders
in html format.
40
41
42
Install PyPOM:
While typing 'pip install PyPOM' make sure its entered after '>>>'
43
Install Selenium:
python.exe -m pip install pytest-selenium
pytest-xdist:
python.exe -m pip install pytest-xdist
tox:
python.exe -m pip install tox
Cookie cutter:
python.exe -m pip install cookiecutter
44
45
Script:
from selenium.webdriver import Chrome
driver = Chrome("C:\\Python27\\chromedriver.exe")
driver.set_page_load_timeout(10)
driver.get('https://sameplewebsite')
46
driver.find_element_by_id('username').send_keys('XXXXXXXX')
driver.find_element_by_id('password').send_keys('XXXXXXXX')
driver.find_element_by_css_selector('#login button').click()
driver.get_screenshot_as_file("F:\\Selenium using
Python\\Screenshots\\loginpage.png")
driver.quit()
If you really wish to learn how to run the tests without errors,
watch the video suggested in the link given below:
https://www.youtube.com/watch?v=zRrubJ13I8s
47
searchInput: by.name('q'),
searchResultLink: by.css('div.g > h3 > a')
},
performGoogleWebsiteSearch: function (searchQuery) {
var selector = page.googleSearch.elements.searchInput;
// return a promise so the calling function knows the task has
completed
return driver.findElement(selector).sendKeys(searchQuery,
Selenium.Key.ENTER);
}
};
Reference to the samples above:
https://github.com/john-doherty/selenium-cucumber-js
50
51
https://drive.google.com/open?id=0B70x0BZZV5lzUXprYVZ
yVFRpaDg
Alternative link for the same file:
https://goo.gl/yZ5xfP
Instructions to download: Click on the link-->Open in Chrome--
>Click Download button ('click Download Anyway button' if
asked)-->Extract after download-->Place the Automation Project
Folder in C drive or D drive-->Once Placed, Install Eclipse as per
53
the instructions in this section and follow the steps noted below to
access project.
Install JAVA
Java programming is a famous and important programming
language in testing industry, and the testers with Java knowledge
are paid high in the job markets!
Please download Java from the following link:
http://www.oracle.com/technetwork/java/javase/downloads/index.
html
in the computer. Once the task is performed, kindly check the C:/
Drive's program files folder. This folder should have 'JAVA' folder
with JDK and JRE sub-folders. As soon asthe folders are displayed
on the computer screen, it indicates that the Java installation is
completed but the configuration has to be done to make sure that
the JAVA files are successfully identified by the computer.
JAVA configuration
Once Java has been installed successfully, JAVA_HOME and
PATH has to be set up in the system following the steps noted
below:
Right click on 'This PC' and select Properties:
55
56
Note: Make sure that you have mentioned the path including bin
folder as above. You can take a copy of this path by just clicking
on the bin folder as shown below:
Launch Eclipse
Download latest Eclipse version from http://eclipse.org/downloads/
Once downloaded, please install it and open Eclipse from the
location it is downloaded by clicking on eclipse.exe as shown
below:
58
59
Set workspace for the Eclipse project as this location will be the
primary location to save all the Java files that are going to be used
for the automation framework:
Once the workspace has been provided, the welcome page appears
as shownin the picture below, and 'Workbench' button on the top
right side of the window is to be clicked to view workbench and
write the new programs:
60
Package explorer
This is the left panel where the projects are listed along with source
code of the program required for the automation framework:
61
62
63
64
65
66
67
68
Create a folder name JAR files to have all the relevant JAR
files
When the automation framework is designed, it is a mixture of
more than one extendable jar files downloaded from various source
locations. Moreover, each jar file differs from their old versions
due to latest defect fixes. So it is important to keep all the installed
jar files of the automation framework in this particular folder.
Right click on the project, click on New and click on Folder:
69
Note:Version of the files differson the basis of the time it has been
downloaded.
70
After downloading these files, place them into the JarFiles folder:
71
72
Paste this file into JarFiles folder which is created for the Selenium
Automation Framework:
73
74
Once the files are downloaded, confirm that all the jar files from
this file (including the jar files from sub-folders of this file) are
pasted into JarFiles folder which is created for the automation
framework.
75
Once these files are pasted into JarFiles folder, this may look like
the below structure:
76
Alternatively, both the files can be downloaded from the link given
below:
https://github.com/prashanth-sams/testng-xslt-1.1.2/tree/master/lib
Once these two files are downloaded, place them into the JarFiles
folder:
77
78
Once the file is located in this Package folder, this can be viewed
in Package Explorer:
https://drive.google.com/file/d/0B6vnknygMB3IdzF4X2taWFRR
MVE/edit
JarFiles folder structure after pasting the plug-in:
Select the path of the JarFiles folder and select all the JAR files in
the folder and then click on Open button:
80
Once the files are selected, click on OK button and make sure that
the files are added:
81
Excel readability
Java program should be designed to interact to each column/row of
test data to read and write the data as part of test execution. This
can be done by using Read_XLS.java file.
Download the file from the below link and place it in the utility
folder:
https://drive.google.com/file/d/0B6vnknygMB3INVFqYi03T2FrO
Xc/edit
Alternative Link: https://goo.gl/MC66oD
Utility folder:
82
Suite Utility
It is a best practice to have the test scripts in different test cases
and linked to respective test suites. Hence, each test suite can be
executed with the help of TestNG.
In order to have this flexibility, Suite Utility should be extended
from a JAVA file:
Download file from
https://drive.google.com/file/d/0B6vnknygMB3ISGdURlYwU20x
Wms/edit
Alternative Link: https://goo.gl/z39j5u
Paste the utility Java file in Utility folder:
83
Place the files for logs and TestNG-supported xsl files in xslt
folder:
84
Once the log4j and TestNG result files are saved in xslt folder, it
can be viewed in Eclipse:
85
Once the TestNG files are added to the folder, this can be viewed
as follows:
86
Property file
This file has to be updated with parameters which are required for
the test automation project:
87
88
89
90
Path
Once ANT_HOME and PATH has been set, this can be verified by
entering the command 'ant -version':
91
Similar to the query above, ant clear query should result in BUILD
SUCCESSFUL as the build has been placed in this folder for
compilation:
AutoIT
92
93
Step1:
Place the AutomationFramework folder in C: drive like this:
Step2:
Launch Eclipse from the folder it has been installed (Unlike other
software applications, Eclipse needed to be launched by exe every
time to open and access whereas other software available in
shortcuts or different links to access while launching them).
Open eclipse.exe (preferable Eclipse Luna):
Step3:
Choose the folder of the Automation Framework folder and click
on OK button:
94
95
96
97
Click on the Browse button to choose the project and select both
the checkboxes to search and copy the existing projects. Choose
SAF project in the list and click on OK Button:
98
Right click on the folder SAF, click on Build Path and click on
Configure Build Path:
99
(Follow the same steps mentioned in this section to add all the
external JARs.)
Final steps:
Click on Project--> Clean
100
Note:
Where to start the execution: Step 'Test Execution through TestNG'
in this chapter.
SAF-->testoutput folder-->testng.xml file-->Right click-->Run As-
->TestNG Suite
101
References:
What if there is an error while installing and configuring the
Selenium project in Eclipse?
http://stackoverflow.com/questions/2638016/why-no-projects-
found-to-import
How to setup?
http://www.assertselenium.com/eclipse-2/how-to-setup-a-
webdriver-project-in-eclipse/
http://stackoverflow.com/questions/18492668/how-to-execute-a-
selenium-test-in-java
102
103
'JAVA' folder with JDK and JRE sub-folders. Once these folders
are displayed in the computer, it means that the Java installation
procedure is completed but the configuration is yet to be completed
to ensure that the JAVA files are identified by the computer.
JAVA Configuration:
Once Java has been installed successfully, JAVA_HOME and
PATH has to be set up in the system as follows:
Right click on 'This PC' and select Properties:
Note: Based on your Java version, the folder name will differ. It is
better to navigate to the location and then copy the path as below:
105
Eclipse:
Download the latest eclipse version from
http://eclipse.org/downloads/
Once downloaded, please install it and open Eclipse from the
location it is downloaded by clicking on eclipse.exe.
Cucumber:
Install the Cucumber Plugin into Eclipse. This plugin enables
certain features in Eclipse – e.g. a nice green cucumber icon for
feature files. Also, when you double click on a feature file then it
will open the feature in Eclipse rather than opening notepad.
In Eclipse, go to help->install new software.
106
Click the Cucumber Eclipse Plugin checkbox and then hit next,
next, accept the license agreement and finish.
TestNG:
Follow steps:
1. Click on Help > Install New software
2. Add the linkhttp://beust.com/eclipsein Work with text box
3. TestNG feature will be shown, expand the tree node and then
verify the version.
4. Tick the check box of TestNG
5. Click on Next button and then the Finish button.
Steps to use the existing or ongoing Selenium automation project
in Eclipse:
Step1:
Place the AutomationFramework folder in C: Drive like this:
Step2:
Launch Eclipse from the folder where it has been installed (Unlike
other software applications, eclipse needs to be launched by exe,
every time to open and access, whereas other software available in
the shortcuts or different links to access while launching them).
Open eclipse.exe (preferable Eclipse Luna):
107
Step3:
Choose the folder from the automation framework folder and click
on the OK button:
108
109
110
Click on the Browse button to choose the project and then select
both the checkboxes to search and copy the existing projects.
Choose SAF project in the list and then click on the OK button:
111
112
Right click on the folder SAF, then click on Build Path and then
click on the Configure Build Path as follows:
(Follow the same steps which are mentioned in this section to add
all the external JARs)
Please select JAR files from the JarFiles folder of the project and
then click Open to list the jar files within 'Libraries'. If there are
existing JAR files with incorrect path or highlighted with errors,
remove them and add fresh files from JarFiles folder.
113
Similarly, if JRE System Library exists, that is good to run the test
in java-based framework; if JRE System Library doesn‟t appear in
the Libraries above, click on 'Add Libraries' in the Libraries
section, and then choose the default JRE (respective version
display as third check box) and then click Next and Finish buttons
to display JRE System Library.
114
Select the JRE System Library, and then click onthe Next button:
115
Once the JRE System Library is added without any errors, it will
be listed in the Libraries section of the Build Path; right click on
Java project-->Build Patch-->Configure Build Path-->Libraries to
validate:
116
Final Steps:
Click on Project--> Clean
Note:
Where to start the execution?: Step 'Test Execution through
TestNG' in this chapter
SAF-->testoutput folder-->testng.xml file-->right click-->Run As--
>TestNG Suite
117
References:
What if there is an error while installing and configuring the
Selenium project in Eclipse?
http://stackoverflow.com/questions/2638016/why-no-projects-
found-to-import
How to setup?
118
http://www.assertselenium.com/eclipse-2/how-to-setup-a-
webdriver-project-in-eclipse/
http://stackoverflow.com/questions/18492668/how-to-execute-a-
selenium-test-in-java
119
120
Launch Webdriver
Step1: Sample scripts on web driver initiation
//To Initialize Firefox web browser
WebDriver driver = new FirefoxDriver();
//To set time out 10 seconds.
driver.manage().timeouts().implicitlyWait(10,
TimeUnit.SECONDS);
//To maximize the browser.
driver.manage().window().maximize();
//To navigate to URL.
driver.get("http://www.abctest.com");
//To close the browser.
driver.close();
The above script will launch the respective web page and the close
immediately. This script is sufficient if the browser requirement to
test is only Mozilla Firefox. But most of the test projects are in
need of a cross browser testing. It means that the script written in
Selenium has to be run in either Internet Explorer or Firefox or any
other given browser as per the requirement of the application.
Selenium supports Firefox, Chrome and Internet Explorer widely
and it is easy to run the scripts using cross browsers in Selenium
framework.
As an initial implementation, browser drivers have to be placed in
BrowserDrivers folder in order to use the respective driver based
on the browser selection:
121
loadWebBrowser();
driver.get(Param.getProperty("siteURL"));
Read the data from the excel sheets for the data driven framework
by locating the path of excel files as given below.
124
Install PhantomJS
Download Jason Phantom through
http://phantomjs.org/download.html
Once installed, clicking on the exe file inside the bin folder
displays this command prompt:
125
126
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
127
publicclass phantomjs {
WebDriver driver;
@BeforeTest
publicvoid setup() throws Exception {
//Set phantomjs.exe executable file path using DesiredCapabilities.
DesiredCapabilities capability = new DesiredCapabilities();
//Make sure that the path of exe file has been provided here with /
for //every folder like the below:
capability.setCapability(PhantomJSDriverService.PHANTOMJS_
EXECUTABLE_PATH_PROPERTY,
"C:/Users/naray_000/Desktop/Training
Materials/Installable/phantomjs-2.0.0-windows/phantomjs-2.0.0-
windows/bin/phantomjs.exe");
driver = new
PhantomJSDriver(capability);driver.manage().timeouts().implicitly
Wait(15, TimeUnit.SECONDS);
}
@Test
publicvoid phantomTest() throws IOException{
driver.get("http://www.reed.co.uk/");
driver.findElement(By.xpath("id('topSignInLink')")).click();
//Update your registered user name
driver.findElement(By.xpath("id('topSignInEmail')")).sendKeys("t
[email protected]");
//Update your registered password
driver.findElement(By.xpath("id('topSignInPassword')")).sendKey
s("abcd1234");
driver.findElement(By.xpath("id('topSignInPanel')/div[4]/div/span/
input")).click();
driver.findElement(By.xpath("id('keywords')")).sendKeys("Softwa
re Tester");
driver.findElement(By.xpath("id('location')")).sendKeys("cv313qd
");
128
driver.findElement(By.xpath("id('homepageSearchButton')")).click
();
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("javascript:window.scrollBy(250,350)");
driver.findElement(By.xpath("id('jobSection27977887')/div/header
/div/h3/a")).click();
driver.findElement(By.xpath("id('applyBtn')")).click();
driver.findElement(By.xpath("id('submitBtn')")).click();
//To capture page screenshot and save In D: drive.
File scrFile =
((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("C:\\Test.jpeg"),true);
}
}
Once the JAVA file is added to the project, right click on the java
file and Run As, TestNG suite. Since it is a headless browser test,
it runs in the background and provides the results once completed!
129
Apache Maven helps to build the projects and manage the java-
based projects as Process Object Model (POM) of Maven is widely
used across the IT industry for test automation. Primarily, it is an
excellent build automation tool!
130
131
132
133
134
135
<groupId>SAF</groupId>
<artifactId>MavenProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MavenProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-
8</project.build.sourceEncoding>
136
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
137
Once the files are downloaded, make sure that all the jar files from
this file (including the jar files from the sub-folders of this file) are
pasted into the JarFiles folder which is created for the automation
framework.
138
139
140
Make sure that the added external jar‟s version and the pom.xml‟s
version of Selenium and TestNG resemble the same as per the
script shown below:
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
publicclass WebDriverTest {
WebDriver driver;
@Test
publicvoid verifySearch() {
driver = new FirefoxDriver();
driver.get("http://www.reed.co.uk/");
driver.findElement(By.xpath("id('topSignInLink')")).click();
142
driver.findElement(By.xpath("id('topSignInEmail')")).sendKeys("t
[email protected]");
driver.findElement(By.xpath("id('topSignInPassword')")).sendKey
s("abcd1234");
driver.findElement(By.xpath("id('topSignInPanel')/div[4]/div/span/
input")).click();
driver.findElement(By.xpath("id('keywords')")).sendKeys("Softwa
re Tester");
driver.findElement(By.xpath("id('location')")).sendKeys("cv313qd
");
driver.findElement(By.xpath("id('homepageSearchButton')")).click
();
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("javascript:window.scrollBy(250,350)");
driver.findElement(By.xpath("id('jobSection27977887')/div/header
/div/h3/a")).click();
driver.findElement(By.xpath("id('applyBtn')")).click();
driver.findElement(By.xpath("id('submitBtn')")).click();
driver.quit();
}
}
143
144
Click on New button and then enter the location of the JDK folder:
Set the path as the bin file location of the Maven folder:
145
146
147
148
Build Success:
Once the build is a success, verify that the src folder and the
pom.xml gets created within the MavenProject and then go ahead
and edit the script as described earlier in theEclipse steps.
149
How to add the project into the scheduled tasks of Jenkins and
why?
When the automation tests are long running by themselves and
providing the test results, it is always an advantage with respect to
time as it is utilized in the best possible ways. Many projects target
on the evening test executions as the test runs overnight and
provides the test results by the morning.
150
You can run the Eclipse project from the command line as shown
below:
151
Crone Expression:
String comprised of five fields with whitespace
For Eg: H 16 04 10 * which means 16:4PM; 04: 04th
Day;10:October
152
Selenium IDE
Programming language used in this section: Selenese
More code examples of this section are available from github at:
https://github.com/narayananpalani/testautomation/tree/master/00
3SeleniumIDE-TestProject
Based on Selenese:
Selenium IDE commands are written in JAVASCRIPT and
HTML. So, these scripts are commonly known as Selenese.
153
In the search box, search for Selenium IDE and then download.
Alternatively, navigate to http://www.seleniumhq.org/download/
and then download it from the link given below:
154
155
and specify the format (language) used when saving your test
cases.
Help Menu:
Recording and Run settings
When Selenium-IDE is first opened, the record button is ON by
default.
During recording, Selenium-IDE will automatically insert
commands into your test case based on your actions.
Remember Base URL MODE – Using Base URL to Run Test
Cases in Different Domains
Record Absolute recording mode – Run Test Cases in Particular
Domain
Running Test Cases
Run a Test Case – Click the Run button to run the currently
displayed test case.
Run a Test Suite – Click the Run All button to run all the test cases
in the currently loaded test suite.
Stop and Start – The Pause button can be used to stop the test case
while it is in the running mode. The icon of this button then
changes to indicate the Resume button. To continue, click Resume.
Stop in the Middle – You can set a breakpoint in the test case to
make it to stop on a particular command. This is useful for
debugging your test case. To set a breakpoint, select a command,
right-click and from the context menu select Toggle Breakpoint.
Start from the Middle – You can tell the IDE to begin running
from a specific command in the middle of the test case. This also is
used for debugging. To set a startpoint, select a command, right-
click and then from the context menu select Set/Clear Start Point.
Run Any Single Command – Double-click any single command to
run it by itself. This is useful when writing a single command. It
lets you immediately test a command you are constructing, when
you are not sure if it is correct. You can double-click it to see if it
runs correctly. This is also available from the context menu.
TC#1
Open http://www.abctest.com
Click id=abc-search
Type id=abc-search Tool efficient
Click //form[@id='abc-search-
form']/div/span/i
pause 3000
assertTitle abctest.com |
imagination at work
assertTextPresent ABCTEST is translating
the Industrial element
verifyText css=h2 Learn about
ABCTEST's
industry
solutions that
are powering
the Industry
157
158
of tools
clickAndWait link=Selenium
WebDriver
verifyTitle Selenium WebDriver Selenium
WebDriver
assertTitle Selenium WebDriver Selenium
WebDriver
159
160
to Automate?
assertText link=Introducing Selenium Introducing
Selenium
verifyElement link=Brief History of The
Present Selenium Project
assertElement link=Selenium‟s Tool Suite
Present
verifyText link=Choosing Your Selenium Choosing Your
Tool Selenium Tool
assertText link=Supported Browsers and Supported
Platforms Browsers and
Platforms
verifyText link=Flexibility and Flexibility and
Extensibility Extensibility
assertElement link=exact:What‟s in this
Present Book?
verifyText link=The Documentation The
Team–Authors Past and Documentation
Present Team–Authors
Past and Present
assertElement link=Selenium-IDE
Present
verifyText xpath=(//a[contains(text(),'Intr Introduction
oduction')])[2]
verifyTitle Selenium Documentation –
Selenium Documentation
assertElement link=Installing the IDE
Present
verifyElement link=Installing the IDE
Present
assertElement link=Opening the IDE
Present
verifyText link=IDE Features IDE Features
verifyElement link=Building Test Cases
Present
assertText link=Using Base URL to Run Using Base URL
Test Cases in Different to Run Test Cases
Domains in Different
162
Domains
verifyText link=Using Base URL to Run Using Base URL
Test Cases in Different to Run Test Cases
Domains in Different
Domains
assertElement link=Selenium Commands –
Present “Selenese”
assertElement link=Script Syntax
Present
verifyText link=Test Suites Test Suites
assertText link=Commonly Used Commonly Used
Selenium Commands Selenium
Commands
verifyText link=Verifying Page Elements Verifying Page
Elements
assertText link=exact:Assertion or exact:Assertion or
Verification? Verification?
verifyElement link=Locating Elements
Present
verifyText link=Matching Text Patterns Matching Text
Patterns
assertElement link=The “AndWait”
Present Commands
verifyElement link=The waitFor Commands
Present in AJAX applications
verifyText link=Sequence of Evaluation Sequence of
and Flow Control Evaluation and
Flow Control
assertElement link=Store Commands and
Present Selenium Variables
verifyText link=Store Commands and Store Commands
Selenium Variables and Selenium
Variables
assertText link=JavaScript and Selenese JavaScript and
Parameters Selenese
Parameters
verifyText link=echo - The Selenese Print echo - The
Command Selenese Print
163
Command
assertText link=Alerts, Popups and Alerts, Popups,
Multiple Windows and Multiple
Windows
verifyText link=Debugging Debugging
assertText link=Writing a Test Suite Writing a Test
Suite
verifyText link=User Extensions User Extensions
assertText link=Format Format
verifyText link=Executing Selenium-IDE Executing
Tests on Different Browsers Selenium-IDE
Tests on Different
Browsers
assertText link=Troubleshooting Troubleshooting
verifyTitle Selenium Documentation –
Selenium Documentation
verifyElement link=Introducing WebDriver
Present
assertText link=exact:How Does exact:How Does
WebDriver „Drive‟ the WebDriver
Browser Compared to „Drive‟ the
Selenium-RC? Browser
Compared to
Selenium-RC?
verifyText link=WebDriver and the WebDriver and
Selenium-Server the Selenium-
Server
assertElement link=Setting Up a Selenium-
Present WebDriver Project
verifyText link=Migrating from Selenium Migrating from
1.0 Selenium 1.0
assertElement link=Introducing the
Present Selenium-WebDriver API by
Example
verifyElement link=Selenium-WebDriver API
Present Commands and Operations
assertElement link=Driver Specifics and
Present Trade-offs
164
Your Test
assertText link=Learning the API Learning the API
verifyText link=Reporting Results Reporting Results
assertText link=Adding Some Spice to Adding Some
Your Tests Spice to Your
Tests
assertText link=Server Options Server Options
verifyText link=Specifying the Path to a Specifying the
Specific Browser Path to a Specific
Browser
assertText link=Selenium RC Selenium RC
Architecture Architecture
verifyText link=Handling HTTPS and Handling HTTPS
Security Popups and Security
Popups
assertText link=Supporting Additional Supporting
Browsers and Browser Additional
Configurations Browsers and
Browser
Configurations
assertText link=Troubleshooting Troubleshooting
Common Problems Common
Problems
assertText link=Test Design Test Design
Considerations Considerations
verifyText link=Introducing Test Design Introducing Test
Design
assertText link=Types of Tests Types of Tests
assertText link=Validating Results Validating Results
verifyText link=Location Strategies Location
Strategies
assertText link=Wrapping Selenium Calls Wrapping
Selenium Calls
assertText link=UI Mapping UI Mapping
verifyText link=Page Object Design Page Object
Pattern Design Pattern
verifyText link=Data Driven Testing Data Driven
Testing
166
167
168
Note:
Selenium IDE is not working on Firefox version 55 onwards (as
of 9th Aug'2017)
Reference:
https://seleniumhq.wordpress.com/2017/08/09/firefox-55-and-
selenium-ide/
169
170
171
Command Explanation:
java –jar:Launching a jar file (which is the compressed java
package
selenium-server-standalone-3.4.0.jar :Name of the selenium server
downloaded
-port 4444 :Port where Selenium listening to the nodes
-role hub:Act as a hub to execute the tests concurrent
Press Ctrl+C to end the session of the server and ensure that the
server is closing down.
Launch the website given below to see the status of the Selenium
Grid:
http://localhost:4444/grid/console
172
Use the command given below to launch the Selenium grid (if the
Selenium grid is already running as hub with the previous
command please keep it running and do not close. Use a separate
command prompt opened to type the command given below in the
same folder hierarchy of the Selenium server):
173
Error Handling:
If you receive a message such as this error, then try an alternative
command format:
Command:
java -
Dwebdriver.ie.driver="E:/BrowserDrivers/IEDriverServer.exe" -
Dwebdriver.chrome.driver="E:/BrowserDrivers/chromedriver.exe"
-jar selenium-server-standalone-3.0.4.jar -role node -hub
http://localhost:4444/grid/register -port 5566
If this code is also not working, then there are issues related to
Win7 of X64 in the Selenium Grid, hence remove the
configuration items of the browser and then run as shown below:
java -jar selenium-server-standalone-3.0.4.jar -role node -hub
http://localhost:4444/grid/register -port 5566
Further reference to these type of issues tracked under:
https://github.com/SeleniumHQ/selenium/issues/3170
174
Refresh the web page to see the browsers in the Selenium Grid:
How to write the first code in the Selenium Webdriver and run in
the Selenium Grid?
Prerequisites:
Refer Selenium Framework (Hybrid) using Java (and TestNG) in
this book to build the framework and use this code sample in the
java-based Selenium test and run in the Selenium Grid (by running
the test in TestNG).
Code Sample:
//Import section of the code written in Java programming
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
175
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import org.openqa.selenium.By;
import static org.testng.Assert.fail;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
//Class name of the program.File has to be saved in
GridConcurrentTest.java to work in the framework with the help of
Selenium and TestNG:
public class GridConcurrentTest {
WebDriver driver = null;
private StringBuffer verificationErrors = new StringBuffer();
// Transfer the details of the platform and driver and URL tolaunch
@Parameters({ "strPlatform", "driver", "url" })
@BeforeTest(alwaysRun = true)
public void setup(String strPlatform, RemoteWebDriver driver,
String url) throws MalformedURLException {
DesiredCapabilities bwsrSettings = new DesiredCapabilities();
bwsrSettings.setPlatform(org.openqa.selenium.Platform.WINDO
WS);
if (driver.equalsIgnoreCase("Internet Explorer"))
bwsrSettings = DesiredCapabilities.internetExplorer();
if (driver.equalsIgnoreCase("Firefox"))
bwsrSettings = DesiredCapabilities.firefox();
if (driver.equalsIgnoreCase("chrome"))
bwsrSettings = DesiredCapabilities.chrome();
176
// This section launches the driver within the grid node by talking
to hub of Selenium Grid.
driver = new RemoteWebDriver(new
URL("http://localhost:4444/wd/hub"),bwsrSettings);
driver.manage().timeouts().implicitlyWait(30,
TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get(url);
}
@AfterTest
public void afterTest() {
driver.quit();
}
}
Note:
Refer the code base at GitHubto build this same code inside the
following framework:
https://github.com/narayananpalani/testautomation/tree/
master/SAF
177
Launch Eclipse from the folder where it has been installed (Unlike
other software applications, eclipse needs to be launched by exe
every time to open and access whereas other software available in
the shortcuts or different links to access while launching them).
Open eclipse.exe (preferable Eclipse Luna):
Step3:
Choose the folder of the automation framework folder and then
click on the OK button:
178
179
180
181
Click on the Browse button to choose the project and then select
both the checkboxes to search and copy the existing projects.
Choose SAF project in the list and then click on the OK Button:
182
Right click on the folder SAF, click on Build Path and then click
on Configure Build Path as follows:
183
(Follow the same steps which are mentioned in this section to add
all the external JARs)
Please select the JAR files from the JarFiles folder of the project
and then click Open to list the jar files within 'Libraries'. If there
are existing JAR files with incorrect path or highlighted with
errors, remove them and add fresh files from JarFiles folder.
184
Similarly, if JRE System Library exists, that is good to run the test
in java-based framework; if JRE System Library doesn‟t appear in
the Libraries above, click on the 'Add Libraries' in the Libraries
section, and choose the default JRE (respective version display as
third check box) and click Next and Finish buttons to display JRE
System Library.
185
Select JRE System Library and then click the Next button:
186
Final Steps:
Click on Project--> Clean
187
Right click on a package to add a java file for Selenium Grid Tests:
188
Once the file has been created, paste the sample code inside as
shown below:
All imports go next to the package name:
189
190
191
<classes>
<class name="com.stta.SuiteOne.GridConcurrentTest" />
</classes>
</test>
<test name="Windows+InternetExplorer Test" >
<parameters>
<parameter name="platform" value="Windows" />
<parameter name="browser" value="InternetExplorer " />
<parameter name="url" value="http://webdriverinselenium.com"
/>
</parameters>
<classes>
<class name="com.stta.SuiteOne.GridConcurrentTest" />
</classes>
</test>
<test name="Windows+Firefox Test" >
<parameters>
<parameter name="platform" value="Windows" />
<parameter name="browser" value="Firefox" />
<parameter name="url" value="http://webdriverinselenium.com"
/>
</parameters>
<classes>
<class name="com.stta.SuiteOne.GridConcurrentTest" />
</classes>
</test>
<test name="Windows+chrome Test" >
<parameters>
<parameter name="platform" value="Windows" />
<parameter name="browser" value="chrome" />
<parameter name="url" value="http://webdriverinselenium.com"
/>
</parameters>
<classes>
<class name="com.stta.SuiteOne.GridConcurrentTest" />
192
</classes>
</test>
</tests>
</suite>
193
194
Examples:
|Name|
195
|Tester|
|Expert|
Step Definitions:
this.Given(/^I open angularJS.org$/, function (callback)
{
browser.get('https://angularjs.org');
});
196
197
198
Test Requirements
Earlier sections talked about the framework and the comparison
between automation tools. The next step is to understand how the
framework has to be constructed technically. But strong
fundamentals on test requirements, test plans, scenarios and test
cases are required in order to proceed on automation essentials.
So, this chapter basically explains the testing basics as a
prerequisite.
Requirements are any statement describing the functionality that is
expected of the system. It is always needed in order to be able to
design the test and it is also important to understand that it can be
introduced at any given level. The more details in the requirement,
results in easier test scenarios. Although a set of requirements can
be provided, it can never be complete or testable as required.
An example of a requirement is that a customer should be able to
place orders online or cancel online orders. This would be
classified as a high level requirement. In order to deal with this
requirement, we have to go through the concept of scenarios.
The requirements should always be needed to design a test. The
statement describes any behavior or any functionality that someone
expects from the system. Requirements can come in different
levels of details .The more the requirements for us the easier it is to
test because we know that the requirements are never complete and
will never be testable.
Requirements are illustrations that describe what is expected of the
system, it is always important that before you move to the next
step of software testing, you need to understand what is expected
of the system in the requirements document.
Please refer the Sample Test Requirement section to understand
how testable requirements look and how to derive the scenarios
from the requirements.
Test Plans
Master Test Plan contains a set of important project details on
testing activities such as Summary, Test Items, Environment,
References, Comprehensive Assessment, Identification of
Intermittent issues, Summary of Results, Evaluation, Limitations,
Summary of Activities and Approvals.
199
Refer the sample test plan section for detailed section specific
examples.
Test Scenarios
Sometimes the requirements may not be elaborative or complete;
this could simply be because, for every requirement, there may be
several or multiple scenarios expected to give similar results, these
attributed to conditions that may happen along the line of
production.
The system needs to be tested on these multiple scenarios in order
to increase the chances of having a more reliable and efficient
system free from errors, which is the ultimate target of the project
as well as the software testing team. This also helps in having a
much more predictable system.
Test Cases
More Test Case Examples for this section:
https://github.com/narayananpalani/testautomation/tree/master/00
1FunctionalTestingProject-TrainingInstitute
In order to make sure that the scenarios are tested from one
scenario to another scenario in a systematic way, the team needs to
come up with the test cases, were all the scenarios will be tested
individually. Each case will be tested according to what has been
specified in the requirement document e.g. the conditions
associated with a particular test case such as a precondition and
postcondition which is the expected outcome.
These groups of test cases with similar requirements are bundled
up in one to create a test set. A test set is a group of test cases that
require the same steps to be executed. And they are executed by
creating a test script; these can be done for both manual and
automated testing.
Formula for test case: Input + precondition -> Postconditions +
output
Test cases are the means by which we test the scenarios. For each
scenario, we have a number of test cases. Each test case consists of
200
a set of inputs that are going to be fed into the system and
precondition are all the conditions that exist before a test case.
For example:
Preconditions: all facts about the input e.g. card used, order has not
been canceled, card is still valid etc.
Input =order number
Postconditions: output = confirmation message e.g. order has been
canceled. As a result of order cancelation, card has been refunded
with the correct amount.
Refer to the sample test cases section for the detailed test cases
with each column and with example test cases.
201
202
Step3-Sprint
Sprint is a short duration milestone that allows the team to prepare
a chunk of the project to get in to ship ready state. Sprint is
generally ranged between 3 and 30 days depending on the product
release backlog. A project usually includes several sprints.
At the beginning of the Sprint, a team will have Sprint Planning
Meeting where the product owner and the team decide what will be
done. They select the features which occupy the highest priority
from the release backlog.
204
205
Test Estimation
Earlier chapter discussed about Sprint-based Agile Testing. This
chapter will help in understanding how important is the estimation
for automation projects. Due to incorrect estimation, large
automation projects led to expensive failures in the history. So this
chapter illustrates the details about how to estimate any test
automation assignment.
Projections of Testing Project based on the testing process, data,
extracts are basically derived from test estimation using various
test estimation techniques. Time and resources required for testing
and the number of estimations required for businesses have been
calculated before initiating the testing activities.
Test effort, duration, infrastructure, resources, required expertise,
tools and need for test environments are estimated and analyzed as
part of test estimation.
Test effort
Amount of time required to write the test scenarios, review of test
scenarios, write test cases, test case review, test data preparation,
test execution time, defect tracking time, backup time on each test
execution cycle due to environment issues, number of test
environment and systems required.
Duration
Schedule for Test Design (Scenario, Test Cases, Test Data, Test
Script Preparation on Test Automation), Schedule for Smoke Test,
Schedule for Test Execution, Schedule for Test Reports and Sign-
off.
Resources
Number of test resources required for functional (manual,
automation) and non functional tests (performance, penetration,
usability tests).
Tools
Required tools for test management, test case management, test
configuration management, test automation, defect reporting tool,
test report tool.
206
Test Environments
Smoke Test Needs (Environment Shakedown Tests/Environment
Readiness Test), Number of test environments required, Number of
systems required in each test environment and their code versions.
Cost Estimation
A cost estimate is the approximation of the cost of a testing
program, project or operation such as change request testing. It has
a single total value along with a set of component values as part of
testing assignment.
Famous cost estimation techniques in the testing projects are
classified as top down method, bottom up method, analogues and
parametric test estimation.
Top-Down Test Estimation
Efforts are estimated at task level such as cost of test case
preparation, test execution etc. Individual work items as part of the
testing project have been taken into consideration. This estimation
starts from main modules and stepping into downstream of the
components and estimate the cost involved in each component.
This means, calculation of the test project duration and the cost by
comparing it with the set of the existing projects which were
successful.
It is a fast and easy approach compared to other estimation models
and the only negative factor is that the bottleneck cases are not
taken into consideration such as test environment downtime, poor
quality of test design etc.
208
Time Estimation
Duration of test cycles, test resources availability and the time
required to complete the test activities are calculated as part of test
time estimation process.
CPM (Critical Path Method), CCM (Critical Chain Method),
Resource Leveling, PERT (Program Evaluation and Review
Techniques) and Monte Carlo Simulation are some of the famous
techniques used as part of the test estimation methods for testing
projects.
Critical Path Method (CPM)
The critical path calculates the longest path of the activities to the
end of the testing project. So, the highly critical path where the
earliest and the shortest time in each activity can start and finish
without extending the project is highly important. The visibility
into the critical path allows the test managers to prioritize the
activities and take appropriate actions to meet the schedule.
209
210
Existing
Assumptions,
Test
Exclusions,
Project
Constraints
Records
211
212
Factors Weights
Simple Average Complex
Number of user 3 4 6
inputs(Number of Excel
Sheets for user inputs)
Number of user outputs 4 5 7
(Test extracts as Excel
Files)
Number of user inquiries 3 4 6
(SQL Scripts used to
extract search results in
Automation Framework)
Number of files 7 10 15
(Application Under Test)
Number of external 5 7 10
interfaces
(Driver scripts used to
interact with different
systems and automation
engine)
213
Solution:
Basic Count Function Types Weight Total
10 simple inputs 10 * 3 30
7 simple Outputs 7*4 28
3 average Inquiries 3*4 12
6 average Logical files 6 * 10 60
1 complex Interface 1 * 10 10
Unadjusted 140
Total
214
COCOMO calculation
Assuming an organic type project with an estimated size = 132,000
lines of code.
Effort: PM = 2.4(128) 1.05 = 392 person-months
Productivity: 132,000 DSI / 392 PM = 336 DSI/PM
Schedule: TD = TD=2.5 (PM) 0.38 = 24 months
Avg. Staffing: 392 PM / 24 months = 16 FSP
Where,
FSP = full-time-equivalent staff person
Collective test estimation technique
Automation Leads discuss with stakeholders of the project and get
the single outcome as test estimation. Project Managers, Business
Analysts, Developers are usually involved in this discussion to
contribute inputs to the test estimation.
215
Analysis
Sample Framework Design Stage
11 Library Architecture Design 20
12 Data Mapping Design 20
13 Driver Script Design 20
14 Utility Script Design 20
Total Automation Framework 156
Development Hours
216
Automation Lead
7 Object Recognition 3
8 Tool Usability Comparison 5
9 Features Testability 5
10 Tool Support-Framework 5
Compatibility Analysis
Sample Framework Design Stage-
From Automation
Lead/Automation Test Analysts
11 Library Architecture Design 20
12 Data Mapping Design 20
13 Driver Script Design 20
14 Utility Script Design 20
Total Automation Framework 156
Development Hours
217
218
Calculations:
Note: Assuming that the efforts required for manual testing and
automation testing are getting reduced from Sprint 3 onwards.
As per the ROI calculation, the return gets added to the project
only when the automation is implemented successfully for the first
three sprints and moved on to fourth sprint.
219
Activity list
Set of Test Scripts can be listed as part of the activity list and
executed based on the satisfied criteria like most of the test scripts
should be scheduled based on the preconditions and
postconditions. So, the continuation of the script execution can be
maintained till the end.
Example1:
Given below in the list, Test 9A and 9B are parallel tests. So, they
get completed in 3 hrs time whereas all the other tests can start
their execution only when the previous tests are completed (not
necessary that the precondition tests have to be passed).
220
Example2:
Given below in the example, tests are listed based on the priorities
where Critical is the top priority followed by High, Medium and
the bottom priority is Low. When the project required only
important tests to be executed, 2 Critical and 4 High priority tests
can be executed in order to complete the test execution.
Bar chart
The best representation of automation test execution scheduling is
possible through Bar Charts when multiple Automation Testers are
involved in the test project.
Example1
The table below shows the number of days of the tests completed
and the remaining number of days to test the application in a
sample project.
221
222
Network diagram
List of Tasks of Automation Tests can be converted to network of
activities which connects one to another to represent the complete
automation tests in graphical representation.
Example 1:
Assume the table given below is the list of activities involved in
the automation test project. Each activity has to be updated with
the effort estimation, start date, end date and the resource allocated
to the activity.
223
System
Compatibility
Test
2 Activity
2.1 Task
Sub
2.1.1 Task:Regression
Tests 1
Sub
2.1.2 Task:Regression
Tests 2
Sub
2.1.3 Task:Regression
Tests 3
Sub
2.1.4 Task:Regression
Tests 4
2.2 Task
Sub
2.2.1 Task:Regression
Tests 5A
Sub
2.2.2 Task:Regression
Tests 5B
3 Activity
3.1 Task
Sub
3.1.1 Task:Regression
Tests 6
Sub
3.1.2 Task:Regression
Tests 7
Sub
3.1.3 Task:Regression
Tests 8
224
225
Once the network of automation tests has been designed, they can
be listed further to calculate the time estimated for each tests in the
table given below.
2.3 Task
3 Activity
3.1 Task
3.2 Task horizontal
bar
3.3 Task
3.4 Task
4 Activity
226
227
228
MAINTAIN
229
230
231
232
233
234
IF Loop:
Sample Test Script in IF loop for HP UFT:
This if loops checks the length of the sChars. If it is more than 0
then it checks the value if it belongs to the category between 97
and 122. If yes, it displays message box to enter upper case as first
letter. Else it displays the words in ascending order as output.
Dim sChars
Dim nCharCode
sChars = "UnifiedFunctionalTesting"
If Len(sChars) > 0 Then
nCharCode = Asc(sChars)
If nCharCode >= 97 And nCharCode <= 122 Then
MsgBox "The first char must be uppercase"
Else
MsgBox nCharCode
End If
End If
235
End If
Else
CheckText = "Please enter something for the sText"
End If
End Function
For further reading and practice, download the projects at
https://github.com/narayananpalani/testautomation
236
237
239
Ranorex
Programming language used in this section: C#
In order to start the new test, perform the actions suggested below:
File>Click New Solution
New>Test Case
New>Recording solution
Click Record>Global Recording>Start
Note:Click on the web page, and after performing all the actions,
click on Stop button.
240
241
Creation of macro
Microsoft VB Editor is the environment used to create or edit
macros and VB scripts. The complete automation script and the
logic of automation framework can be updated at Microsoft VB
Editor.
Following are the steps to be followed to create automation
framework with subroutines/macros:
-Open an excel sheet (latest version)
-Press Alt+F11 (shortcut key to open MS VB Editor) or
alternatively select Developer Tab, click on Visual Basic button.
242
243
Message box:
244
245
Result:
246
Script:
Public Sub welcome()
MsgBox " Excel Macro Automation Framework "
strLoginID = Cells(2, 1).Value
strPwd = Cells(2, 2).Value
Cells(2, 3).Value = strLoginID & "is the user id and " &
strLoginID & " is the password."
End Sub
Result:
End Select
If Cells(Row, 1) <= 5 Then
Cells(Row, 2).Value = "The Browser selection is " & result
Else
MsgBox "Enter right number for the browser and continue"
End If
Next
End Sub
Valid result:
248
249
250
251
252
253
254
255
Click on the ReadFile button and see the data updated in the sheet:
Similarly, introduce a new button with the name Write File to write
back to the same location in excel is possible through the below
script:
Script:
In ReadForm:
Private Sub CommandButton1_Click()
TextBox1.Text = Sheet1.Cells(3, 2).Value
256
In Sheet1:
Public Sub RUN()
ReadForm.Show
End Sub
257
258
259
Write the sample scripts given below to understand the Excel VBA
code:
Worksheets(1).Name = "Source"
Worksheets(2).Name = "Target"
Worksheets(3).Name = "Comparison"
dtReport = Now()
Worksheets("Comparison").Range("A1:D1").MergeCells = True
Worksheets("Comparison").Cells(1, 1).Font.ColorIndex = 5
Worksheets("Comparison").Cells(1, 1).Font.Bold = True
260
intRow = 3
intCol = 1
intRow = intRow + 1
Worksheets("Comparison").Cells(intRow, intCol) = "Source"
261
Worksheets("Comparison").Cells(intRow, intCol).Font.Bold =
True
intRow = intRow + 1
intTotalSource = 0
intInternalCol = 1
Do While (intInternalCol <=
Worksheets("Source").UsedRange.Columns.Count)
intInternalRow = 1
printColHeading = "N"
Do While (intInternalRow <=
Worksheets("Source").UsedRange.Columns(intInternalCol).Rows.
Count)
SourceValue = Worksheets("Source").Cells(intInternalRow,
intInternalCol)
TargetValue = Worksheets("Target").Cells(intInternalRow,
intInternalCol)
If Not SourceValue = TargetValue Then
If printColHeading = "N" Then
Worksheets("Comparison").Cells(intRow, intCol + 1) =
Worksheets("Target").Cells(1, intInternalCol)
printColHeading = "Y"
intRow = intRow + 1
End If
Worksheets("Comparison").Cells(intRow, intCol + 2) =
intInternalRow
Worksheets("Comparison").Cells(intRow, intCol + 3) =
SourceValue
Worksheets("Comparison").Cells(intRow, intCol + 4) =
TargetValue
intRow = intRow + 1
intTotalSource = intTotalSource + 1
End If
intInternalRow = intInternalRow + 1
Loop
intInternalCol = intInternalCol + 1
262
Loop
intRow = intRow + 1
Worksheets("Comparison").Range(strRange).MergeCells = True
Worksheets("Comparison").Cells(intRow, 1).Font.ColorIndex = 5
Worksheets("Comparison").Cells(intRow, 1).Font.Bold = True
Worksheets("Comparison").Cells(intRow, 1) = "Total Number of
Difference : " & intTotalSource
intTotalTarget = 0
intRow = intRow + 3
Worksheets("Comparison").Cells(intRow, intCol) = "Target"
Worksheets("Comparison").Cells(intRow, intCol).Font.Bold =
True
intRow = intRow + 1
intInternalCol = 1
Do While (intInternalCol <=
Worksheets("Target").UsedRange.Columns.Count)
intInternalRow = 1
printColHeading = "N"
Do While (intInternalRow <=
Worksheets("Target").UsedRange.Columns(intInternalCol).Rows.
Count)
TargetValue = Worksheets("Target").Cells(intInternalRow,
intInternalCol)
SourceValue = Worksheets("Source").Cells(intInternalRow,
intInternalCol)
If Not SourceValue = TargetValue Then
If printColHeading = "N" Then
Worksheets("Comparison").Cells(intRow, intCol + 1) =
Worksheets("Source").Cells(1, intInternalCol)
printColHeading = "Y"
intRow = intRow + 1
263
End If
Worksheets("Comparison").Cells(intRow, intCol + 2) =
intInternalRow
Worksheets("Comparison").Cells(intRow, intCol + 3) =
SourceValue
Worksheets("Comparison").Cells(intRow, intCol + 4) =
TargetValue
intRow = intRow + 1
intTotalTarget = intTotalTarget + 1
End If
intInternalRow = intInternalRow + 1
Loop
intInternalCol = intInternalCol + 1
Loop
intRow = intRow + 1
Worksheets("Comparison").Range(strRange).MergeCells = True
Worksheets("Comparison").Cells(intRow, 1).Font.ColorIndex = 5
Worksheets("Comparison").Cells(intRow, 1).Font.Bold = True
Worksheets("Comparison").Cells(intRow, 1) = "Total Number of
Difference : " & intTotalTarget
End Sub
264
265
266
Set mysheet1=Workbook1.Worksheets("Sheet1")
Set mysheet2=Workbook2.Worksheets("Sheet1")
267
cell.Interior.ColorIndex = 3
mismatch=1
End If
Next
If Mismatch=0 Then
Msgbox "No Mismach exists"
End If
'close the workbooks
Workbook1.close
Workbook2.close
myxl.Quit
set myxl=nothing
268
269
270
271
272
Test objects are viewed using this feature and information such as
parent hierarchy, inheritance hierarchy, test object properties, non-
value properties and method that can be used for those objects.
Windows objects are also captured from Test Object Inspector!
273
Best practice:
Evaluate the tool by testing the sample application and analyzing
the test object-capturing method in order to perform Proof of
Concept for test automation readiness.
274
275
Step 5 – Identify how the objects are mapped for each test script:
Once the test script is recorded, recognized mappings of logical to
physical names of classes and objects in the application are stored
in following format:
277
278
279
the service and use the shipment system till the end of the service
which can be called the integration of the complete services.
280
open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-
1.0.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<soapenv:Header>
<To
xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http
://localhost:63682/Service1.asmx</To>
<Action
xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http
://localhost:63682/Service1.asmx?op=UpdateRoomStatus</Actio
n>
<ReplyTo
xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<Address>http://localhost:63682/Service1.asmx</Address>
</ReplyTo>
<MessageID
xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">uui
d:ceb2798e-76d9-433b-87de-2da0e96557d3</MessageID>
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-
200401-wss-wssecurity-secext-1.0.xsd">
<UsernameTokenxmlns="http://docs.oasis-
open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-
1.0.xsd"
xmlns:ns15="http://schemas.xmlsoap.org/ws/2006/02/addressingi
dentity" xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-
secureconversation/200512"
xmlns:ns13="http://www.w3.org/2003/05/soap-envelope"
wsu:Id="uuid_f794ba10-e1a0-40ae-b184-909efbd1e2e9">
<Username xmlns="http://docs.oasis-
open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-
1.0.xsd">IGRUser</Username>
<Password xmlns="http://docs.oasis-
open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-
1.0.xsd" Type="http://docs.oasis-open.org/wss/2004/01/oasis-
200401-wss-username-token-profile-
1.0#PasswordText">*****</Password>
</UsernameToken>
281
</Security>
</soapenv:Header>
<soapenv:Body>
<b:HTNG_HotelRoomStatusUpdateNotifRQ
EchoToken="Echo22222" TimeStamp="2014-08-17T09:30:47Z"
Version="1.0">
<b:POS>
<b:Source>
<b:RequestorID Type="10" ID_Context="SUPERHOTEL_PMS"
ID="PMS1">
<b:CompanyName>Superhotel</b:CompanyName>
</b:RequestorID>
</b:Source>
</b:POS>
<b:PropertyInfo ChainCode="HotelChain"
BrandCode="HotelBrand" HotelCode="HotelHotel"/>
<b:Room RoomID="EE12345">
<b:Devices>
<b:Device ID="2341ae3c" FriendlyName="MB-12345"
Description="Mini Bar" Class="InRoomRefreshmentCenter">
<b:PriorHealthStatus Value="ERROR" Reason="UNKNOWN"/>
<b:CurrentHealthStatus Value="OPERATIONAL"
Reason="POWER_CYCLED">Manual device reset
performed</b:CurrentHealthStatus>
</b:Device>
<b:Device ID="ef3278ea" FriendlyName="OS-12345"
Description="Ceiling Sensor"
Class="OccupancyDetection">
<b:PriorHealthStatus Value="ERROR"
Reason="LOW_BATTERY"/>
<b:CurrentHealthStatus Value="OPERATIONAL"
Reason="BATTERY_REPLACEMENT">Device
online.</b:CurrentHealthStatus>
</b:Device>
</b:Devices>
</b:Room>
282
</b:HTNG_HotelRoomStatusUpdateNotifRQ>
</soapenv:Body>
</soapenv:Envelope>
SOAP messages can be sent using Excel VBA (refer the section of
Excel VBA automation to understand the Visual Basic Editor).
Update SERVER address with valid address for the URL it is
getting used below.
Option Explicit
xmlns:xsi=""[URL="http://www.w3.org/2001/XMLSchema-
instance"]http://www.w3.org/2001/XMLSchema-
instance[/URL]""
xmlns:xsd=""[URL="http://www.w3.org/2001/XMLSchema"]htt
p://www.w3.org/2001/XMLSchema[/URL]""
xmlns:soap=""[URL="http://schemas.xmlsoap.org/soap/envelope/
"]http://schemas.xmlsoap.org/soap/envelope/[/URL]"">"
sEnv = sEnv & " <soap:Body>"
sEnv = sEnv & " <login
xmlns=""[URL="http://www.ca.com/UnicenterServicePlus/Servi
ceDesk"]http://www.ca.com/UnicenterServicePlus/ServiceDesk[/
URL]"">"
sEnv = sEnv & " <username></username>"
sEnv = sEnv & " <password></password>"
sEnv = sEnv & " </login>"
sEnv = sEnv & " </soap:Body>"
sEnv = sEnv & "</soap:Envelope>"
With xmlhtp
.Open "post", sURL, False
.setRequestHeader "Host", "webservices.gama-system.com"
.setRequestHeader "Content-Type", "text/xml; charset=utf-
8"
.setRequestHeader "soapAction",
"[URL="http://www.ca.com/UnicenterServicePlus/ServiceDesk"]
http://www.ca.com/UnicenterServicePlus/ServiceDesk[/URL]"
.setRequestHeader "Accept-encoding", "zip"
.send sEnv
xmlDoc.LoadXML .responseText
responseText = .responseText
End With
openTag = "<loginReturn"
closeTag = "</loginReturn>"
startPos = InStr(1, responseText, openTag) + 10
endPos = InStr(1, responseText, closeTag)
startTagPos = InStr(startPos, responseText, ">") + 1
' Parse xml for returned value
284
Response:
HTTP/1.1 200 OK
Cache-Control: private, max-age=0,public
285
Step2:
Analyze what needs to be parameterized?
Answer: Inputs can be parameterized. In the request above:
<Celsius>25</Celsius>
Step3:
Create a new excel file, insert a button and update with Input
column and input value:
286
287
288
289
Extract
Transform:
Analyse,
Clean and
Transform
Load:
Data Movement
and Load
290
Define/Code
Data Modelling Extraction
Tool Rules
Data Definition
MDDB
Metadata
Repository
RDBMS
Extract Program
Generation
Source Database
291
OLTP Systems
Transform
Extract Load
OLTP Systems Data Warehouse
STAGING AREA
OLTP Systems
292
ETL tools
Huge number of transformation rules with a GUI (graphical user
interface) can be specified by ETL tools. These ETL tools can
generate programs to transform data across the database. Multiple
data sources can be controlled, and data redundancy can be
addressed to the greater extent!
Metadata can be generated as output from ETL tools, and most of
the tools run multi-threaded-environment-based low-cost servers to
benefit the ease of tool usage!
What is SQL?
SQL is a structured query language for storing, manipulating and
retrieving data that stored in relational database. The names of
some relational databases are MySQL, MS Access, Oracle, Sybase
and Informix.
294
Class.forName(dbClass).newInstance();
// DB Connection is getting established here:
Connection con = DriverManager.getConnection(DB_URL,
DATABASE_USER, DATABSE_PASSWORD);
// Statement object to send the SQL statement to the Database
stmt = con.createStatement();
}
catch (Exception e)
{
e.printStackTrace();
}
}
@Test
public void test() {
try{
//Insert the SQL query within the Selenium Script here:
String query = "select * from table t where empid=101";
// Get the contents of t table from DB
ResultSet res = stmt.executeQuery(query);
// Print the result untill all the records are printed
// res.next() returns true if there is any next record else returns false
while (res.next())
{
System.out.print(res.getString(1));
System.out.print("\t" + res.getString(2));
System.out.print("\t" + res.getString(3));
System.out.println("\t" + res.getString(4));
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
@After
296
297
Object Recognition
In earlier chapters, the topics are covered on how the tools are
used along with sample document format for test plan, test cases
and other test team document methods.In this chapter, an
important topic has been discussed on how automation tools
capturing the human usability using object properties recognition!
When user manually operates the functions on the web pages or
the applications, the same steps are automated using the object-
capturing method of automation tools. This is a process of pattern
recognition algorithm using feature-based or the property-based
techniques by every automation tool.
298
299
300
301
Selenium has been growing since 2011 and overtaken QTP in 2015
due to the hunt for Selenium in the market by a number of people ;
hence, Selenium Webdriver is popular and competent enough to
get implemented like QTP in test automation projects, whereas
Appium has started its growth only since 2013. But it has been
growing in a consistent speed.
302
303
304
306
Click on the android sdk zip file available in the section 'Windows'
if tests are being written in a window-based desktop:
307
308
Once Android SDK zip file has been clicked, read the entire terms
and conditions and click on OK to proceed further:
Once zip file has been downloaded to your target computer, have it
saved in SDK folder within E drive:
Extract the zip file and save under SDK folder within E: drive (for
example). Alternatively, you can save in any drive available within
your hard disk:
309
Once the file has been extracted, navigate to SDK Manager exe file
and click on it to proceed the installation:
310
311
Once Android SDK Manager has been launched, please see the list
of available android files for installation and the entire list will get
upgraded whenever new version of androidis being released:
312
1
Appium.io(11Dec2016),URL: http://appium.io/slate/en/v1.0.0/?ruby#system-
setup-android
314
Click on Install _ package button after selecting all the files from
relevant Android folder. For example, if 4.4.2-based android
device is used for testing, select all the files within the folder of
android 4.4.2 before clicking on Install button. It is to be confirmed
that the desktop or laptop is not switched off until installing the
complete package and showing tick mark in the status of each file.
Once android-version-based files are installed, expand the folder
'Tools' and select relevant build tools. In case of using 4.4.2
mobile, select all those build tools files available with version of
your mobile API. If your mobile API is 24 for an android version
of 7.0, you need the below (as an example):
315
316
317
318
319
Click on Advanced Tab and click New within the frame of User
Variables:
320
322
Similarly, copy the path of tools folder that is available within the
android installation package and paste it in path of environment
variable and end with semicolon:
323
How to check if android has been installed properly and the path
has been set correct?
Connect the mobile to your computer using relevant cable to
recognize the mobile from computer and navigate to command
prompt:
Note: Not all the cables help in recognizing the mobile within
computer; hence, the best way is to use the branded cable of
particular mobile's type. For example, if the mobile is HTC, use
cable of HTC to connect from mobile to computer.
324
Once command prompt has been launched, type 'adb devices' and
press enter:
If device has been listed within the command prompt, it tells that
the android installation is perfect and mobile device has been
recognized. If the mobile has not been listed, ANDROID_HOME
and PATH in environment variable has to be rechecked.
Install Node JS
Navigate to Google and type Install Node.js or alternatively
navigate to the website nodejs.org/en/download:
Make sure that 'Windows Installer' section has been clicked. If the
web page has been redesigned over a period of time, navigate to
the section where window-based installers are available if your
computer is based on Windows operating system:
325
326
327
Enter the file name in command prompt and press enter to launch
the installer. Once Installer opened, click on Next button on
Node.js setup:
328
329
330
331
332
333
334
335
Launch Appium:
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
Download Selenium Server and place it inside the folder as per the
details below:
354
355
356
357
358
359
360
361
362
363
364
@Test
public static void main(String[] args) throws
MalformedURLException, InterruptedException{
DesiredCapabilities
capabilities=DesiredCapabilities.android();
capabilities.setCapability(MobileCapabilityType.BROWSER_
NAME,BrowserType.CHROME);
capabilities.setCapability(MobileCapabilityType.PLATFORM
,Platform.ANDROID);
capabilities.setCapability(MobileCapabilityType.PLATFORM
_NAME,"Android");
capabilities.setCapability(MobileCapabilityType.DEVICE_N
AME,"Narayanan Palani");
//capabilities.setCapability("device","Android");
//capabilities.setCapability("app", "Chrome");
capabilities.setCapability(MobileCapabilityType.VERSION,
"4.4.2");
//WebDriver driver = new RemoteWebDriver(new
URL("http://127.0.0.1:4723/wd/hub"), capabilities);
//driver.wait(2000);
//driver.get("http://www.yahoo.com");
URL url=new URL("http://127.0.0.1:4723/wd/hub");
WebDriver driver=new AndroidDriver(url,capabilities);
driver.get("https://www.google.co.in/?gws_rd=ssl");
driver.findElement(By.id("lst-ib")).sendKeys("Selenium
Webdriver");
driver.findElement(By.name("btnG")).click();
driver.findElement(By.name("hdtb-msb/[3]/a")).click();
}
}
365
367
368
369
370
Selenium 1
Release Date 2004
Tools Selenium IDE,Selenium Core,Selenium
RC,Selenium Server
Advantages Jason Huggins-Project Manager for Selenium
Core
Table-based Runner
Three columns
Selenium Core' Designed by Jason for Time
and Expenses System
Since there were defects from Internet
Explorer,Firefox,Opera for the Javascript
Application (Time and Expenses System), he
decided to run the tests in javascript and drive
the application
Disadvantages Incredibly difficult to manage table-based
scripting hence Selenium RC introduced
371
372
What is Selenium3?
Selenium 3
Release Approximately around 13-Oct-16
Date
Tools Selenium Webdriver,Selenium
IDE,Appium[for mobile]
Advantages Beginning of W3C compliance Protocol
373
Example:
driver.findelement(By.id“textbox”));
Class
Name
Value
Text (Link text , Partial Link Text)
XPATH (Relative X path )
CSS (Fastest Locator)
DOM
Recommended object: Request developer of the project to
introduce an attribute for object called data-automation and use it
in the automation framework such as:
Example:
driver. findElement(By.xpath("//*[@data-automation='test-
username']");
374
375
376
377
Right click on any object – lets say Google search button and
choose Inspect Element to see the name(btnK) and use it in
Selenium IDE:
378
store 40 Practical
parseInt(storedVars['Theory'])+parseInt
storeEval addTotal
(storedVars['Practical'])
echo ${addTotal}
Have the selenium IDE on Record mode and right click on the
object, choose “Show All Available Commands.”
381
382
383
Xpath Helper for Chrome (but this would not help in running
Selenium IDE tests since IDE meant for firefox only):
384
http://51elliot.blogspot.co.uk/2008/02/selenium-ide-goto.html
Example:
How to get a data from html table cell using Selenium IDE?
storeTable (command)
385
386
Why there are two types of commands such as type and typekeys?
First command types the entire word in one go, whereas the second
(typeKeys) just types one letter at a time!
387
388
389
390
391
Note: All these jar files are to be included, not just one jar file
displayed in Section1.
392
Add relevant JAR files (refer all the jar files from Section 1 and 2
and include all of the here) which will be listed in the Project in
Package Explorer under the section 'Referenced Libraries' once
added:
Reference: https://github.com/Matt-B/cucumber-js-selenium-
webdriver-example
Where you will find this file in framework: cucumber-js-selenium-
webdriver-example-master\cucumber-js-selenium-webdriver-
example-master\features
File Name: google.feature
Feature File:
Feature: Candidate Verification Form
As an internet user
In order to find out job in SAP
I want to be able to submit the candidate verification form
394
.sendKeys("1");
this.driver.findElement({ name: ' ss-submit'})
.click();
});
};
“Then” condition sends the user inputs to the page and click on
submit button hence form is getting submitted.
Prerequisite for this project – Chrome Driver:
Chrome Driver can be installed from
http://chromedriver.storage.googleapis.com/index.html
Once installed, add the reference to the 'Path' in Linux box as
follows (if the driver is placed in drivers folder within D drive),
396
export PATH=$PATH:~/D:/Drivers/chromedriver
Validate if it is working as expected (by entering chromedriver in
your terminal and validate the response like the below):
[naru@computer ~]$ chromedriver
Starting ChromeDriver (v2.11) on port 9515
Only local connections are allowed.
Press Ctrl+C to come out of the above message and navigate to the
folder where the script is placed by entering cd <path> command;
If the project folder is selenium-automation-framework-using-
javascript,enter as:
cd selenium-automation-framework-using-javascript
Once navigated to the project folder,enter:
npm install
Install grunt (or gulp) which will be used for test running purpose
(just like TestNG in Selenium Java projects)
Use gruntfile.js to run the tests and produce results like the
below:
[naru@computer selenium-automation-framework-using-
javascript]$ grunt
Running "jshint:files" (jshint) task
>> 4 files lint free.
397
1 scenario (1 passed)
2 steps (2 passed)
398
399
What are the most frequently used browsers for Selenium Tests
in the IT industry?
Firefox, Chrome and Internet Explorer(IE)
Note:
IE 11 need custom configurations to get it worked. Please refer:
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDri
ver
Which are the browsers I can run the Selenium Webdriver 3.0
tests?
Firefox [Need a Gecko Driver to run tests. Refer:
https://github.com/mozilla/geckodriver/]
Chrome [Refer:
https://sites.google.com/a/chromium.org/chromedriver/]
Internet Explorer
[Refer:https://github.com/SeleniumHQ/selenium/wiki/InternetExpl
orerDriver]
Opera
Microsoft Edge
Ghost
Safari
browser.findElement(By.name(“loginID”)).sendKeys(“narayanan.
p”);
400
browser.findElement(By.name(“pwd”)).sendKeys(”abcde”);
browser.findElement(By.name(“signinButton”)).click();
}
catch (Exception errText)
{
errText.printStackTrace();
}
401
Selenium RC
Server
(Hub)
Node
Registration
IE/Chrome/
Firefox/Safari
402
Details:
ant :Configured build tool
Dport: Port where the nodes setup to run
Dhost Hub which is started with Selenium RC
DhubURL= Respective hub URL such
ashttp://localhost:4444/console
403
405
406
Book Chapter-
Based References
Narayanan Palani. (2017, August 02). Test Automation [Web
log post]. Retrieved from
https://github.com/narayananpalani/testautomation.
Selenium. (2017, August 02). Selenium Official Website [Web
log post]. Retrieved from http://www.seleniumhq.org/.
Aravind. (2016, September 07). Software Testing Tutorials and
Automation [Web log post]. Retrieved from
http://www.software-testing-tutorials-
automation.com/p/selenium-webdriver.html.
Selenium. (2016, September 07). Selenium [Web log post].
Retrieved from
https://code.google.com/p/selenium/wiki/GettingStarted.
Specflow. (2016, September 07). Specflow [Web log post].
Retrieved from
https://github.com/techtalk/SpecFlow/wiki/Unit-test-providers.
Specflow.org. (2016, September 07). Specflow.org [Web log
post]. Retrieved from http://www.specflow.org/getting-
started/#InstallSetup.
PhantomJS. (2016, September 07). PhantomJS [Web log post].
Retrieved from http://phantomjs.org/download.html.
Stackoverflow. (2016, September 07). How Schedule Build in
Jenkins [Web log post]. Retrieved from
http://stackoverflow.com/questions/7000251/how-schedule-
build-in-jenkins.
RelevantCodes. (2016, September 07). RelevantCodes [Web
log post]. Retrieved from http://reportunit.relevantcodes.com/.
IBM. (2016, September 07). IBM Functional [Web log post].
Retrieved from http://www-
03.ibm.com/software/products/en/functional.
HP. (2016, September 07). HP UFT [Web log post]. Retrieved
from http://www8.hp.com/uk/en/software-solutions/unified-
functional-automated-testing/.
Borland. (2016, September 07). Silk Test [Web log post].
Retrieved from http://www.borland.com/en-
GB/Products/Software-Testing/Automated-Testing/Silk-Test.
407
____________________________
i
NARAYANAN PALANI. (2016, September 14), Certified Member Profile[Web log
post]. Retrieved from http://www.ibm.com/certify/profile?palanin6
ii
UNICOM. (2016, September 14), India Testing Awards 2016[Web log post]. Retrieved
from http://www.unicomlearning.com/2016/India_Testing_Awards/index.html
iii
UNICOM. (2016, August 31), India Testing Awards 2017[Web log post]. Retrieved
from
http://www.unicomlearning.com/2017/India_Testing_Awards/
iv
NARAYANAN PALANI. (2016, September 14), LinkedIn[Web log post]. Retrieved
from https://uk.linkedin.com/in/narayananpalani
v
DOCUMENTS.MX, (2016, September 14), ADCOM 2009 CONFERENCE
PROCEEDINGS[Web log post]. Retrieved from http://documents.mx/documents/adcom-
2009-conference-proceedings.html
408
INDEX
activity list – 37, 200
Agile Project - 1
Analogues Test Estimation - 189
assertElementPresent - 144
assertions - 150
asserts - 92, 108, 136
assertText – 141, 144, 146
assertTextNotPresent - 141, 382
assessors – 5, 136, 138
Automation Framework function point count - 193
Automation Return on Investment 36, 198
Automation Test Engine Installation - 196
automation test project - 203
Automation Test Scheduling – 37, 200
Availability - 7
BDD – 5, 33, 40
Bottom-Up Test Estimation - 188
C++ Programming - 28
COCOMO – 36, 382
COCOMO Calculation - 195
Collective Test Estimation Technique 36, 196
Cost Estimation - 187
Cost of licenses - 198
Crashing Compression Technique - 190
Critical Chain Method - 190
Critical Path Method (CPM) - 190
Delphi Test Estimation Technique - 36, 197
ETL tools 39, 270
Excel sheet – 37, 221
409
Extensibility – 7, 145
Fast Tracking Compression Technique - 191
Five Phase of Test Automation – 37, 207
functional regression - 206
JAVA_HOME – 49, 52, 357
Key word driven testing - 206
Macro Security - 222
manual test analysts - 198
Monte Carlo Simulation – 189, 192
Network Diagram – 37, 203, 205
NUnit - 21
Parametric Test Estimation – 187, 189
PERT - 36
Portability - 8
Priority - 201
Program Evaluation and Review Techniques – 36, 181, 189
Quick Test Professional - 180, 206
Recording and Run - 138
Regression Tests - 201
Reliability 7, 270
Resource Leveling on CPM - 190
Saxon - 67
Selenium IDE – 45, 39, 112, 141
SOA - 38
Stop and Start - 139
Subroutines - 221
System Utility command - 212
Test Data Sheets – 192, 236
Test effort - 187
Test Environments - 187
test execution scheduling - 202
Test Schedule Compression Techniques – 36, 190
Testing Process - 206
Time Estimation - 189
Toggle Breakpoint - 139
410
411
412