Software Test Automation With Open Source Software
Software Test Automation With Open Source Software
Itai Agmon
Who Am I?
• CTO of Top-Q
• Main contributor of the JSystem project
• Creator of the Difido project
• My laptop runs Linux
1
Why do I like OSS Projects?
• It’s built by passionate communities of developer
• Real solutions to real problems
• Rate of innovation is faster.
• There’s no vendor lock-in. Remember SilverLight
• You can “look under the hood”
• No back doors. _NSAKEY
• Oh, and it’s free
“Given enough eyeballs, all bugs are shallow.”
Eric S. Raymond
2
3
Automation tools and libraries
4
So, Selenium?
5
Test Automation Frameworks
Tests Layer
Inversion of Control
Could be
Programmatically, Text Based, GUI Parameters
Reporting
Common Interface
Infrastructure Layer Setup and Teardown
Layered Architecture
6
First - Functional Tests or NFT
The higher we go
• More unreliability End
QA/
• Greater cost
• Slower feedback
to End Automation
/GUI Teams
Integration/
API
R&D
Unit Tests
7
What is the programming language?
Coding Skill
8
Code Based Approach
@Test
public void testEditAccount(){
DashboardPage dashboardPage = web.getDashboardPage();
AccountsPage accountsPage = dashboardPage.
getTopMenuPage().
clickOnCustomersItm().
clickOnAccountsItm();
EditAccountDetailsMainTab mainTab =
accountDetailsPage.clickOnEditAccountLnkAndGoToEditAccountsPage();
mainTab.enterTextToFirstName(firstName);
mainTab.enterTextToLastName(lastName);
MSTest
9
Who Are The Automation Customers?
Coding Skill
Coding Skill
Coding Skill
Layered Architecture
Tests Layer
QA
Common Interface
Infrastructure Layer
Automation
Eng.
10
UI Based Approach Frameworks
Gauge
Gauge
Robot
Framework
11
Behavior Driven Development (BDD)
12
Who Are The Automation Customers?
Coding Skill
Coding Skill
Coding Skill
QA Automation Eng. R&D Developer
13
Not only must Automation be done; it must also be seen to be done
• Start test
• End test
• Fail test
• Log message Console
Excel/CSV
Automation Report
Tests Manager
DB
HTML
XML
System Under
Test
Parameterization
@Parameters({ "first-name" })
<suite name="My suite"> @Test
<parameter name="first-name" value="Cedric"/> public void testSingleString(String firstName) {
System.out.println("Invoked testString " + firstName);
<test name="Simple example"> assert "Cedric".equals(firstName);
>-- ... --< }
**/
* Test with different parameters
/*
@Test
@TestProperties(name = "Test with file '${file}' string '${str}' integer ${i}
date ${date}", paramsInclude = {
"file", "str", "i", "date", "strArr" })
public void testWithParameters() {
report.report("File: " + file.getAbsolutePath());
report.report("Date: " + date.toString());
report.report("String: " + str);
report.report("Integer: " + i);
}
14
Additional Framework Services
Inversion of Control
Parameters
Reporting
Fixtures
Concurrency
Environment Configuration
peripheral systems
15
Peripheral Systems Types
• Scheduler (CI/CB)
• Test Management Systems (QC, TestLink, MTM)
• Resource Manager
• Report Server
• Reports BI provider
• Source Control
• Remote Agents Manager
• Report Generator
16
Q&A
17
Automations in a
Continuous Deployment
Environment
Matan Goren QA Automation Tech Lead
Who we are
• More than 82 million registered users
• 28 million family trees
• Website, mobile apps (iOS and Android), desktop
apps (windows and Mac)
• 2.6 billion profiles (names in family trees)
• 7 billion historical documents and records. Including
the world’s largest collection of newspapers
• 200 million photos
• 42 languages
• 275 employees
18
Where we were
• All manual QA
• Repetitive tasks
• Time consuming
• Two service packs a week
• Holding back development
• SPC size limits error handling
19
“In software, when something is painful, the way to reduce
the pain is to do it more frequently, not less.”
- David Farley
The CD mindset
20
RND Goals
• Risk reduction to production
• Small incremental changes are easier to monitor and
revert in necessary
• Has lower impact on the system
• Increasing R&D velocity
• Avoiding wasted time on merges and complex
coordination before dist
• Allow R&D and product to experiment and innovate
more frequently
QA Goals
• Provide a safety net
• Avoid the bottleneck of manual sanity testing
• Reliability
• No flaky tests
• No false failures
• QA E2E test should not be the new bottleneck
21
CD Flow (simplified)
Post-dist
E2E tests
Canary Pre-dist
Server E2E tests
Responsibilities
• QA are responsible for E2E tests only
• Dev write and maintain Unit tests
• E2E tests are written during development process
• All QA members monitor CD suite results
• CD E2E tests are NOT acceptance tests
22
Timing
• CD flow from commit to prod is ~25 minutes
• Current QA CD suite takes 3 minutes on average
• Runs in parallel to some of the jobs in the CD flow
• Limited by time frame of parallel jobs
• Still have room for further growth
Challenges of CD
And how we face them
23
Challenges of CD cont.
• Failure visibility
• Slack messages for individual failed tests
• Browser console logs in report
• Screenshots in report
• Post dist – production server logs in the report
(Using Elasticsearch)
• Large scale tests refactoring due to changes
• Ability to run tests with a patch instead of
committing code that doesn’t correspond to
production
Challenges of CD cont.
• CD halt on failure
• Fast response time for failure. All QA members
monitor the relevant channel in slack
• Fast adaptation to feature flags
• Implemented feature flags for tests
24
Challenges of CD cont.
25
Framework
• Ruby
• Cucumber.io
• Page-Object Gem
• Grid Grouper
• Cuke_Slicer gem
• Jenkins
• Watir-webdriver
• Selenium Grid/Grid Extras
• Appium
• Appium_lib
• Xcode simulator
Ruby
• Easy language for inexperienced developers
• Open source community is very active
• It ain’t Java!
26
Watir-webdriver
• Native to Ruby
• Cleaner than Selenium
• Adds methods not native to Selenium
• “Being able to select an element by a explicit
identifier” –watirmelon.com
Page-Object gem
• Provides a simple interface to define and interact with
elements on a page
• Works with both Watir and Selenium
• Simple way of introducing OOP without a lot of technical
knowledge required
• Page factory module handles common page classes
action
27
Cucumber.io
• BDD tool
• Tests are written in plain English
• Makes for easy debugging
• Easy move from Manual test to automatic test
• Helps soften the introduction to programming
• “Top down” programming
• Write a step
• Define the step
• Make it work
• Pre and post test hooks
Cucumber Feature
Tags specify the suites
28
Step Definitions
Directly with Watir-Webdriver
Using page-object
Page-object example
Defining page-object
Using page-object
29
Native Mobile Apps
• Tests run nightly on the build or on demand
• Using two Mac minis as test machines
• Device parameters are passed from Jenkins (or
configuration if running locally)
• The apps are built on the tests machines and deployed
to the simulator\emulator
• Support for iOS and Android within existing infra
• iOS simulator, Android emulator and Appium server are
opened by command from within the code
30
Native Mobile Apps
• iOS simulator, Android emulator and Appium server are
opened by command from within the code
31
Grid Grouper
• Homegrown tool
• Takes a given suite and distributes the test across several
groups
• Utilizes cuke_slicer gem
• Checks the feature flags and filters out tests that are
turned off
• Multiple reports problem is solved by a report merger
tool that was developed in house
Jenkins
• Chuck Norris!
• Was already in use by RND
• Open source (lot’s of available plugins)
• Schedule automated builds
• Kick off manual builds with a few clicks
• Control build parameters (server, suite, etc)
• Can build in any of our environments with any
combination of tags
• Holds build history for a specified amount of time
• Merged report is stored in each build
• Slack and email notifications
32
The Grids
• Comprised of Selenium Grid and Selenium-Grid-Extras
• Selenium-Grid-Extras makes the basic setup streamlined
• Gives extra features such as:
• Pulling in updated drivers for all browsers
• Also for Selenium itself
33
“A challenge only becomes an obstacle when
you bow to it.”
- Ray A. Davis
Challenges QA faces
34
Questions?
We are hiring
Thanks!
AA Milne
35
Mobile Testing
Open(ish) Source Solutions
https://www.youtube.com/watch?v=p8A4yq
N4_9A
Mobile Testing
Open(ish) Source Solutions
111
What’s ahead
• Mobile evolution
• Motivation
• Define UI Testing (with mobile emphasis)
• UI Mobile testing – Than VS Now
Mobile evolution
112
Mobile evolution
Mobile evolution
113
Mobile evolution
Mobile evolution
114
Motivation
Motivation
115
Motivation
Motivation
116
Motivation
Motivation
117
UI Testing
Experimental
manual tests
The higher we
go
End
QA/
• More unreliability to End Automation
• Greater cost
• Slower feedback /GUI Teams
Integration/
API
R&D
Unit Tests
Define UI Testing
118
UI Testing – Then
• Image based
UI Testing – Then
119
UI Testing – Then
UI Testing – Then
120
UI Testing – Now
• Instrumentation based
• Virtualization support, better simulators
• Android UiAutomator/IOS UIAutomation
Frameworks
• Requires signature/permission
UI Testing – Now
• UI Automator Viewer
121
UI Testing – Now
• Appium
– Allows to locate UI elements and perform
various operations on them
– Multiple OS Support (Win, Lin, Mac)
– Supports native and hybrid applications
– Supports iOS and Android
– Supports real devices and simulators
UI Testing – Now
122
UI Testing – Now
UI Testing – Now
123
UI Testing – Experitest
https://youtu.be/fWM_DBQ95p8
UI Testing – SauceLabs
• Appium Hub
• Run your code against multiple devices
online
• No need to configure prior testing
• Manual Testing
https://youtu.be/kCJwwRXUTdo
124
UI Testing – GenyMotion
https://www.youtube.com/watch?v=50PR7
ocy_IU
125
Resources
http://powerlisting.wikia.com/wiki/File:Devolution_of_Man.jpg
http://www.geek.com/mobile/evolution-of-the-cell-phone-depicted-in-papercraft-1309666/
http://www.hexapolis.com/2015/07/28/12-video-game-franchises-then-and-now-the-graphics-evolution/
App Annie, BI Inteligence
http://worthstuff.blogspot.com/2010/05/lg-ally-mobile-phone-with-slide-out.html
http://www.kinvey.com/how-long-to-build-an-app-infographic/
http://www.kinvey.com/wp-content/uploads/2013/01/how-long-does-it-take-to-build-an-app-kinvey-1500x834.png
http://www.factslides.com/s-Mobile-Phones
http://jwtyler.blogspot.co.il/2010_10_01_archive.html
http://www.androidauthority.com/nokia-qwerty-keyboar-107145/
http://www.formotus.com/14018/blog-mobility/figuring-the-costs-of-custom-mobile-business-app-development
http://decor10blog.com/design-decorate/decorating-ideas/apple-design-team-abandoning-sketchbooks-for-the-apple-
pencil-says-jonathan-ive.html
https://www.quora.com/Why-Microsoft-failed-at-mobile
126
The Road To Automated Testing
Tal Tsach-Cohen
QA Manager Hexagon Technologies
About Me
• In QA 6 Years
• Studied .Net 2yrs at SELA while working
• Introduced automation to company when QA
was 2 members. Today I manage a team of
14.
• Previously was a chef in San Francisco for 8
years. This experience was more relevant than
you would think.
127
Who Are We?
• 15 Members.
• 5 Teams
• 7 Automation, 7 Manual including team
leaders.
• 4000 tests run nightly.
128
Components
•.Net C#
•Selenium, Appium, Applitools, Git, NUnit
•All frameworks developed in house page object model for GUI.
•2 Solutions Server and Client systems.
•Same tests for both web applications, and same tests for iOS and
Android only element mapping is changed via configuration files.
•Jenkins for deploy to QA and running tests.
•Custom reporter including video, HTML Report and integration with
Elastic Search.
•Test analysis with Kibana and Elastic Search.
•Notifications via Slack.
Why C#?
129
Why Jenkins?
•Off the clock POC was needed to demonstrate need for investing in
automation.
•System is extremely complex, upwards of 50 components working
together making stability an issue.
•Core components have no unit testing so E2E testing was needed to
make up for deficit.
•Due to system complexity and need for known system wide state running
parallel tests on core business component (Trading Platform) is almost
impossible.
•Multitude of technologies used in system require high competency of
automation developers. Oracle DB, redis, kafka, couchDB, mongoDB,
NodeJS, Cassandra, Linux, ZMQ and more…
130
More Challenges Specific To Hexagon
•Server side automation team (No GUI) needs hard to find skill set of high
level developer with QA orientation.
•Automation developers are responsible for writing code as well as
defining tests. Finding testers with aptitude for both disciplines has been a
challenge.
•Inability to use external solutions due to lack of access to QA
environments from outside LAN.
131
Where We Are Today
132
133
134
135
What Is Next?
136
137
Page Object Design Pattern – De-facto
Standard for Test Automation Projects
Itai Agmon
138
139
Image courtesy of Stuart Miles at FreeDigitalPhotos.net
140
So, What is That Page Object Thingy Anyway?
141
How About Those Record and Playback technologies?
@Test
public void testRegisterAndLogin() throws Exception {
// Register new user
driver.findElement(By.linkText("Register")).click();
driver.findElement(By.id("firstName")).sendKeys(FIRST_NAME);
driver.findElement(By.name("lastName")).sendKeys(LAST_NAME);
String userName = FIRST_NAME + String.valueOf(System.currentTimeMillis());
driver.findElement(By.id("username")).sendKeys(userName);
driver.findElement(By.id("password")).sendKeys(PASSWORD);
driver.findElement(By.tagName("button")).click();
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By
.xpath("//div[text()='Registration successful']")));
// Login
driver.findElement(By.id("username")).sendKeys(userName);
driver.findElement(By.id("password")).sendKeys(PASSWORD);
driver.findElement(By.tagName("button")).click();
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By
.xpath("//h1[text()='Hi " + FIRST_NAME + "!']")));
driver.findElement(By.linkText("Logout")).click();
142
No Biggy, Let’s Use Functions
@Test
public void testRegisterAndLogin() throws Exception {
String userName = registerNewUser(FIRST_NAME, LAST_NAME,
PASSWORD);
Login(userName, PASSWORD);
logout();
}
private void logout() {
driver.findElement(By.linkText("Logout")).click();
}
143
Granularity – Let’s Talk Negative
//Or this
login(user, password, expectSuccess);
144
Page Object Pattern
The Test
@Test
public void testRegisterAndLogin() throws Exception {
LoginPage loginPage = new LoginPage(driver);
loginPage.clickOnRegisterLnk();
145
Navigation
…Adding Navigations
RegisterPage
public LoginPage clickOnRegisterBtn() {
driver.findElement(By.tagName("button")).click();
return new LoginPage(driver);
}
TestRegistration
@Test
public void testRegisterAndLogin() throws Exception {
LoginPage loginPage = new LoginPage(driver);
RegisterPage registerPage = loginPage.clickOnRegisterLnk();
registerPage.typeToFirstName(FIRST_NAME);
registerPage.typeToLastName(LAST_NAME);
String userName = FIRST_NAME + String.valueOf(System.currentTimeMillis()); And what about
registerPage.typeToUserName(userName); negative tests?
registerPage.typeToPasswordTb(PASSWORD);
loginPage = registerPage.clickOnRegisterBtn();
loginPage.typeToUserNameTb(userName);
loginPage.typeToPasswordTb(PASSWORD);
HomePage homePage = loginPage.clickOnLoginBtn();
homePage.clickOnLogoutBtn();
146
Negative Test
@Test
public void testLoginWithWrongPassword(){
LoginPage loginPage = new LoginPage(driver);
loginPage.typeToUserNameTb(FIRST_NAME);
loginPage.typeToPasswordTb("WRONG PASSWORD");
loginPage.clickOnLoginBtnAndStayInLoginPage();
@Test
public void testSuccessfullLogin(){
LoginPage loginPage = new LoginPage(driver);
loginPage.typeToUserNameTb(FIRST_NAME);
loginPage.typeToPasswordTb(PASSWORD);
HomePage homePage = loginPage.clickOnLoginBtnAndGoToHomePage();
}
What do you
actually test
here ?
@Test
public void testLoginWithWrongPassword() {
LoginPage loginPage = new LoginPage(driver);
loginPage.typeToUserNameTb(FIRST_NAME);
loginPage.typeToPasswordTb("WRONG PASSWORD");
loginPage.clickOnLoginBtnAndStayInLoginPage();
147
We Sure Like Things Organized
public class LoginPage extends AbstractPage {
LoginPage
public LoginPage typeToUserNameTb(String userName) {
driver.findElement(userNameBy).sendKeys(userName);
return this;
}
148
We Now Have a Fluent Test
@Test
public void testRegisterAndLogin() throws Exception {
LoginPage loginPage = new LoginPage(driver);
RegisterPage registerPage = loginPage.
clickOnRegisterLnkAndGoToRegisterPage();
homePage.clickOnLogoutBtnAndGoToLoginPage();
@Test
public void testRegisterAndLogin() {
LoginPage loginPage = new LoginPage(driver);
RegisterPage registerPage = loginPage.clickOnRegisterLnkAndGoToRegisterPage();
149
Different Browsers, Different Problems
Layered Architecture
Tests Layer
ActionBot
150
Meet ActionBot
Q&A
151
152
Tips and Tricks Appium Via Selenium
June 2016
On The Agenda
153
Some Numbers
4000+ 70 30,000,000+
Enterprise clients Cities Passengers
Around the globe On all platforms
Automation
Challenges
154
Gett Automation FrameWork
Automation Platforms
GUI Platform:
→ Android - client and Driver app
→ Iphone DBX and client
→ Web -
● Company web
● Customer Care
● Private Web
● Mobile Web
Headles
Hybrid
155
Automation periodic runs
Load Zone
156
Gett Page Object Design pattern within interfaces
Page object is a design pattern that can be implemented as a selenium best practices.
• The Page Object pattern represents the screens of your web app as a series of objects and
encapsulates the features represented by a page.
• A page object is an object-oriented class that serves as an interface to a page of your AUT.
• When we have page with the same functionality/ Object in two different pages u se interfase
Using - AbstractPage
• AbstractPage Class is the place to holds all the wrappers for selenium methods
• Abstract Methods serves all webPages and contain only baseWeb Functionality regardless Buisness logic
157
Gett Web Page Design pattern within interfaces
inherit
AbstractPage()
inherit
AbstractPage()
inherit
AbstractPage()
158
Gett Page Object Design pattern within interfaces
TariffService class
The Interface - for Tariff functionality that implement by two different pages
A Common Method
159
Gett Page Object Design PhoneUserTariffServiceImpl class
• The method FillFixChargeForm() contain its unique functionality and also use
setFixTariffrFromAddressDetailes()
• Every Page holds Sync point to be sure that we in the correct place and the page was loaded
• Wait contain polling - until object found limit by X time !!!
• In case of Failure throws exception
160
Tip - Web Locator and Object Repository - mapping the objects
WebLocator Class
Web Locators Business Logic
Repository
PhoneUserTariffServiceImpl class
Page object Design Pattern -
Main Rules
161
Mobile Client Automation FrameWork
Appium is “cross-platform”: it allows you to write tests against multiple platforms (iOS,
Android), using the same API , based on Selenium API .
• The test use one interface object that implements differents platform - Main interface obj.
• The main business logic object perform all the business logic calls in the system
162
Trick -The Implementor for
IOS platform - Appium Init
iphoneDriver = getTaxiAppium.connect();
driver = iphoneDriver;
// AbstractPage by passing to it the webDriver ;
163
The Implementor for IOS
platform - Appium
pageImpl.clickOnButton.
(iphoneButtons.get(getTaxiButton.name()));
• Example of using the obj “pageImpl” to click on btn using selenium Api
• The Method iphoneButtons.get() transform the the getTaxiButton into our the WebLocatore Object
pageImpl.selectAutoCompleteOptionWithMouse
(iphoneButtons.get(GetTaxiButton.OK.name()));
• Example of using the obj “pageImpl” to click on Mouse using Events selenium Api
164
WE ARE HIRING
● QA Testers
● Automation developers
● Architect
● iOS / Android
● Product Manager
● Product Analyst
● BI
● DevOps
● Big Data
● UX/UI designers
165
Reports
Get the most out of your tests
166
Who Cares About Reports?
167
JSystem
168
It has some drawbacks
• Ugly
• Confusing
• Slow
• Unmaintainable
• Hard to customize
169
JUnit Example
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<testsuite errors="1" failures="1" hostName="agmon-PC" name="JSystem Reporter" tests="9" time="1022.419" timeStamp="Sun May 29
11:13:29 IDT 2016">
<testcase classname="il.co.topq.auto.tests_project.TestsExamples" name="reportError" time="0.227">
<error message="Error" type="class java.lang.Exception">java.lang.Exception: Error
at jsystem.framework.report.RunnerListenersManager.addError(RunnerListenersManager.java:355)
at jsystem.runner.remote.RemoteExecutorImpl$ReaderThread.run(RemoteExecutorImpl.java:368)
</error>
</testcase>
<testcase classname="il.co.topq.auto.tests_project.TestsExamples" name="controlParametersAttributes" time="0.173" />
<testcase classname="il.co.topq.auto.tests_project.TestsExamples" name="testWithParameterProvider" time="0.205" />
<testcase classname="il.co.topq.auto.tests_project.TestsExamples" name="reportWithLevels" time="0.224" />
<testcase classname="il.co.topq.auto.tests_project.TestsExamples" name="testWithReturnParameter" time="0.2" />
<testcase classname="il.co.topq.auto.tests_project.TestsExamples" name="testWithParameters" time="0.161" />
<testcase classname="il.co.topq.auto.tests_project.TestsExamples" name="reportWarning" time="0.136" />
<testcase classname="il.co.topq.auto.tests_project.TestsExamples" name="reportFailure" time="0.142">
<failure message="Fail report was submitted" type="class
junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: Fail report was submitted
at jsystem.framework.report.RunnerListenersManager.addFailure(RunnerListenersManager.java:466)
at jsystem.runner.remote.RemoteExecutorImpl$ReaderThread.run(RemoteExecutorImpl.java:373)
</failure>
</testcase>
<testcase classname="il.co.topq.auto.tests_project.TestsExamples" name="reportSuccess" time="0.105" />
</testsuite>
Cucumber Example
170
TestNG Example
ReportNG Example
171
So I decided to write something on my own
It should be:
• Real time!
• Easy on the eye
• Fast
• Flexible – Add screenshot, files, tables.
• No server
• It should have a weird name
172
Difido Architecture
View Model
Difido Architecture
173
Demo of HTML report
174
Difido Server Architecture
175
How about BI?
Elasticsearch
• Open source
• Java Based
• NoSQL
• Very Scalable (Peta bytes of data) Shay Banon
176
Difido Server Architecture
177
More Features
Success Stories
178
You Can Use It too
• Site: http://top-q.github.io/difido-reports/
• Documentation: https://github.com/Top-Q/difido-
reports/wiki
• Github: https://github.com/Top-Q/difido-reports
Q&A
179
180