Functional programming is reemerging in popularity but can be difficult for you to use at your day job. At the same time automated browser testing is very practical and has become something that every developer can at least dip their toe in. Canopy, a simple framework in F# on top of Selenium for writing UI automation and tests, can be a great way to start learning a functional language. This talk will explore some of the basic functional concepts targeting those are new to functional programming and show how they can be practically used to automate your browser testing.
Convert to study materialsBETA
Transform any presentation into ready-made study materialselect from outputs like summaries, definitions, and practice questions.
2. THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
3. THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
4. 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)
5. THIS TALK
Intro Story
Problem
Why Functional Programming
Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
6. THE PROBLEM(S)
How do we learn how to be a more
functional programmer(s)?
How do we reduce complexity of
automated browser testing?
7. THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
8. 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
13. 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.
21. 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.
28. 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
36. THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
37. 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#
38. 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#
39. 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
40. WHY FUNCTIONAL STORY 2
Develop an application to evaluate the revenue due from Balancing
Services contracts
Existing solution implemented in C#
41. 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
42. 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.
53. 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
55. 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.
56. THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
58. WHAT IS SELENIUM?
A Unified API for Browsers
WebDriver
Server/Grid
IDE (For Recording)
59. 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
60. THIS TALK
Intro Story
Problem
Why Functional Programming & Functional Concepts
Why Functional Stories
F#
Selenium & Why Automated Testing
Canopy
78. 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
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/
#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?