際際滷

際際滷Share a Scribd company logo
FUNCTIONAL BROWSER
AUTOMATION TESTING
FOR NEWBS
Bryan Arendt
@ctrlshiftbryan
Canopy F#
THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
HISTORY OF BRYAN ARENDT
Commodore 64 + Basic (1989)
Guitar (1995)
OSU (1999)
The Sun (2002)
Quit Day Job (2005)
First Heard of F# (2013)
Code Mash (2016)
THIS TALK
Intro Story
Problem
Why Functional Programming
Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
THE PROBLEM(S)
How do we learn how to be a more
functional programmer(s)?
How do we reduce complexity of
automated browser testing?
THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
WHY FUNCTIONAL?
Readability and maintainability
 A function accomplishes a specific task given its arguments. The function does not
rely on any external state
Easier testing and debugging
 They can be tested in isolation
Reduce Code = Reduce Bugs
Easier reiterative development
 the code is easier to refactor, changes to design are often easier to implement
THINKING FUNCTIONALLY
Take parameters Transforms values Returns new values
FUNCTIONAL PROGRAMMING
CONCEPTS
Immutability Expressiveness
Types & Values Pure Functions
FUNCTIONAL PROGRAMMING
CONCEPTS
Immutability Expressiveness
Types & Values Pure Functions
IMMUTABILITY
Values and State cannot be changed once created
Removes side effects
Removes changing state
VALUES INSTEAD OF VARIABLES
Instead of changing the value of an existing variable, create a new
variable with the specified initial value.
In functional programming we bind a value to a name.
Functional Browser Automation Testing for Newbs
Functional Browser Automation Testing for Newbs
FUNCTIONAL PROGRAMMING
CONCEPTS
Immutability Expressiveness
Types & Values Pure Functions
EXAMPLE OF EXPRESSIVENESS
We are going to explore the idea of being terse or expressive.
Im going to have some help from two people
There are only two hard things in Computer Science: cache
invalidation and naming things.
Phil Karlton
Function f
Var x
UNCLE BOB
NAMES
Variable Names
Variables with large scope should be long, and small scope should be
short. Variables scope should be proportional with their length of
names. Variable names like I and j are just fine if their scope is five
lines long.
Function Names
The longer the scope of a function, the shorter its name should be.
Functions that are called locally from a few nearby places should have
long descriptive names, and the longest function names should be
given to those functions that are called from just one place.
Functional Browser Automation Testing for Newbs
IN FUNCTIONAL PROGRAMMING
Functions are commonly named f
Variables are commonly named x
FUNCTIONAL PROGRAMMING
CONCEPTS
Immutability Expressiveness
Types & Values Pure Functions
TYPES & VALUES
Every function is a value
Every value has a type
Entire programs can be type checked for correctness
PASSING A FUNCTION TO A
FUNCTION
FUNCTIONAL PROGRAMMING
CONCEPTS
Immutability Expressiveness
Types & Values Pure Functions
PURE FUNCTIONS: REMOVING SIDE
EFFECTS
Kris Jenkins  What is Functional Programming?
http://blog.jenkster.com/2015/12/what-is-functional-
programming.html
Two types of inputs and outputs
NORMAL
HIDDEN
SIDE-EFFECTS ARE THE
COMPLEXITY 鴛遺掘京掘檎赫
SIDE-EFFECTS ARE THE
COMPLEXITY 鴛遺掘京掘檎赫
FUNCTION W/ HIDDEN INPUT
PURE FUNCTION
REVIEW FUNCTIONAL
PROGRAMMING CONCEPTS
Immutability Expressiveness
Types Pure Functions
THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
WHY FUNCTIONAL  STORY 1
Rachel Reese
http://rachelree.se/rewriting-from-c-into-f/
I rewrote into F# a super simple data transferring app from C#
C# -> F#
70% less time! - F# 2 minutes
25% less code!  140 lines to 103
Bug - processing tremendously more data than needed (F# made this
apparent)
Bug Couple Hours -> 7 Minutes  fixing C#
WHY FUNCTIONAL  STORY 2
Does the Language You Use Make a Difference (revisited)?
http://simontylercousins.net/does-the-language-you-use-make-a-
difference-revisited/
Simon Tyler Cousins @simontcousins
WHY FUNCTIONAL  STORY 2
Develop an application to evaluate the revenue due from Balancing
Services contracts
Existing solution implemented in C#
PROBLEMS
not all of the contracts had been implemented  too complex
hard to maintain the large code base
impossible to test without live data
low confidence in the numbers it produced
failed to evaluate the contracts in near-real-time
DESIGN PRINCIPLE
Stay safe, Stay functional.
In particular, we have an immutable domain model and persistence
store. Pure functions are used to work with this domain model.
Functional Browser Automation Testing for Newbs
Functional Browser Automation Testing for Newbs
Functional Browser Automation Testing for Newbs
Simon Tyler Cousins @simontcousins
HOW CAN WE ALL DO THIS?
How can we convince this guy?
THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
Functional Browser Automation Testing for Newbs
F#
Mostly Functional
Leverage .Net Environment
We can call a compiled C# .Net program or library from F# very easily
Nuget!
C# MOST POPULAR FEATURES
Generics / Type parameterization
Lambda Expressions
Delegates
Type Inference (limited)
F#
Functional Imperative
Haskel,
OCaml
F# C# C
Multi-paradigmFunctional Imperative
MIXED PARADIGM LANGUAGES
If C# is a object oriented language that supports and includes some
functional concepts
F# in the inverse.
Then F# is a functional language that supports object oriented
concepts
LOOKING FOR AN EXCUSE TO USE
F#
CANOPY - F#RICTIONLESS WEB TESTING
one goal in mind, make UI testing simple:
 Solid stabilization layer built on top of
Selenium.
 Quick to learn. Even if you've never done UI
Automation, and don't know F#.
 Clean, concise API.
THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
WHY AUTOMATED TESTING?
Regression
Test More Like A User (High Level)
Combinatorial Testing
Exact Requirements
Many Browsers
WHAT IS SELENIUM?
A Unified API for Browsers
WebDriver
Server/Grid
IDE (For Recording)
SELENIUM ARCHITECTURE
Library- [C#][Ruby][Java][Python][...]
 Navigate to a Page
 Send Keystroke
 Click on Elements
 Read Information
WebDriver API Rest Based Web Service
WebDriver Executable
 translates API calls
 each browser has its own web driver
 Chrome and IE each have separate executables
 Firefox and PhantomJS are built-in
THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
CANOPY F#
Canopy F# .Net C# Nuget
WebDriver
REST Api
WebDriver
Executable
CANOPY
Actions
Assertions
Testing
Configuration
Reporting
Functional Browser Automation Testing for Newbs
OPEN LIBRARIES AND START A
BROWSER
DEFINE A TEST
THE &&& FUNCTION
INFIX FUNCTION
Prefix notation: + 3 4
Infix notation: 3 + 4
Functional Browser Automation Testing for Newbs
NO BRACES
ASSERTION FUNCTIONS
Functional Browser Automation Testing for Newbs
Functional Browser Automation Testing for Newbs
PATTERN MATCHING
Common.fs
Login.fs
Functional Browser Automation Testing for Newbs
THIS TALK RECAP
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
LEARN MORE
LEARN MORE
http://fsharpforfunandprofit.com/
http://fsharpforfunandprofit.com/series/low-risk-ways-to-use-
fsharp-at-work.html
FUNCTIONAL PROGRAMMING @
CODEMASH
Programs that Write Programs: How Compilers Work
 Thursday 4:45 PM Indigo Bay
Functional Programming Basics in ES6
 Thursday 4:45 PM Zambezi
A Developers Journey from Object Oriented to Functional
Programming
 Friday 11:00 AM Zambezi
Erlang, or How I Learned to Stop Worrying and Let Things Fail
 Friday 2:45 PM Orange

More Related Content

Functional Browser Automation Testing for Newbs

Editor's Notes

  • #5: Ever since I was 10 I knew I wanted to be a software developer. Probobably not too different from a lot of people in this. Room. In addition to loving programming I had a hobby of playing guitar in bands. Moved to OSU music introduced me to people. Programming did not. Played in different bands and made musician friends. Joined a band with some friends of previous bands, moved to LA and got signed by Warner Brothers. Still did some programming in things like flash.
  • #20: Is this good naming? The conventional thought is No. http://blog.ploeh.dk/2015/08/17/when-x-y-and-z-are-great-variable-names/
  • #21: Some of you have Some havent
  • #23: Remove noise. This is a much more expressive way of conveying the same information. So when you here that F# is expressive think of this. Dont we want to do the same things with our programming?
  • #27: Show module 3
  • #48: Bill Lumbergh
  • #55: Bill Lumbergh
  • #56: Canopy is our excuse
  • #64: This is canopys Hello World