Quick Overview
Spec Drill
Tackling the tip of the Test Pyramid
1
Test Pyramid – The map
martinfowler.com
1
BDD – Identifying the gap
BDD
TDD
saucelabs.com
1
Webdriver
• The WebDriver specification is a W3C Recommendation
That defines a set of interfaces and a wire protocol that are platform- and language-neutral
and that allow out-of-process programs to remotely control a browser
in a way that emulates the actions of a real person using the browser.
https://www.w3.org/TR/webdriver/
BrowserDriver
JSON Wire Protocol
Generic Webdriver Browser(s)
Framework Framework
JSON Wire Protocol
Remote
Webdriver
Test Code
1
Automation Framework Guidelines
AUTOMATION FRAMEWORK GUIDELINES
GENERAL
• Easy to use (minimum coding skills required)
• Evolution should be driven by practical needs.
• Prefer internal complexity in favor of external simplicity
• Reduce Boilerplate code
DON’Ts DOs
• Create methods with too many parameters • Develop a Domain Specific Language
- Use implicit parameters - your framework should provide a DSL over the
- Optimize for general case underlying automation framework (WebDriver/others)
• Use magic strings / numbers / primitive types - your Page Object Model should provide a DSL over
- Prefer constants or enums your SUT
• Create the need for using “new” • Make It Opinionated on best practices
- Make Factories available • Wait constructs
• Don’t expose low level framework internals / • Navigation
DOM manipulation constructs • POM (WebPage, WebComponent)
• Out of the box activity logging
• Make It Easy to Use and Adopt
WEBDRIVER CHEATSHEET
Id()
FindElement() By
FindElement()
IWebDriver throws IWebElement throws
ElementNotFoundException ElementNotFoundException
Name()
By
FindElements()
does not throw By …
ElementNotFoundException
CssSelector()
By
FindElements()
IWebDriver does not throw IWebElement[]
ElementNotFoundException XPath()
By
Click()
Enabled Until(Func<IWebDriver,Tresult>)
bool WebDriverWait bool
Displayed
bool
Text
IWebElement string
GetAttribute(str)
string MoveToElement(IWebElement)
GetCssValue(str) Actions
string
Submit() Perform()
SPEC DRILL CHEATSHEET
ELEMENT FACTORY LOCATOR FACTORY
Create(IElement, IElementLocator) Create(By, string)
WebElement IElement ElementLocator IElementLocator
CreateNavigation<WebPage>(IElement, IElementLocator) INavigationElement<WebPage>
WAIT BROWSER
ForNoMoreThan(TimeSpan)
Until(Func<booL>) Open<IPage>()
Wait Browser WebPage
WebControl
WHY BUILD AN AUTOMATION FRAMEWORK
Your Your tests are vulnerable
Plain WebDriver SUT to WebDriver / SUT
WebDriver Tests
changes
Plain Your Your tests are vulnerable
WebDriver SUT
WebDriver Tests to WebDriver
with changes
Page Objects Your
PageObjects
Your
Framework Framework WebDriver SUT Your tests are not
Tests
with Vulnerable to
Page Objects WebDriver
Your
nor
(SpecDrill) PageObjects
SUT changes
SPEC DRILL - Features
NUnit
SpecFlow
MsTest
Test Framework More will follow (demand driven)
Support
Configuration Page Objects
Support for POM
construction Control Objects
Underlying Framework / Driver
Initialization
Navigation
Logging Waits
Action / Interaction
Tracking Active
Passive
SPEC DRILL FLOW
1. Pick a Test
Case to • This step should be easy
Implement
• Each distinct page you come
2. Identify
across while going through your test case
Page Objects
Represents a Page Object
3. Identify • Re-ocurring complex web controls or groups
Control Of controls (Menus, search boxes, grids)
Objects are candidates to Control Objects
4. Automate • Write your automated scenario by interacting
your Test With your newly created POM.
Case • You have the option to extract reoccurring interactions
Into methods on targeted Page Objects / Control Objects
to increase automation code reuse.
Futures
Migrate to .NET 5 (currently .NET Core 3)
Simplify Declarative Model
Only rely on Attributes
Remove the need to declare constructors
Catch up with reported bugs
Feature requests
Click and Drag
File Download
Possibly build a JVM variant.
1
Demo
CONTRIBUTE
SpecDrill is OpenSource :
https://github.com/CosminSontu/SpecDrill
Use It and Contribute
Log Issues
Request Features