Date post: | 11-Jul-2015 |
Category: |
Spiritual |
Upload: | mykola-kolisnyk |
View: | 10,390 times |
Download: | 2 times |
Behavior Driven Development (BDD) with Selenium RC
Presented by: Mykola Kolisnyk
About me
Mykola Kolisnyk
Overall experience: 6+ yearsPositions: QA Lead
Senior Automation Consultant Test Automation Architect
Tools: SilkTestTestCompleteSeleniumRFTSoapUI
Co-author: “SilkTest manual” book (http://silktutorial.ru)Portal http://automated-testing.info
About presentation
Behavior-Driven
Development
Typical toolset
Test Designer
xUnit Solution difficulties
Test Automation Engineer
Business AnalystDeveloper
Not all people read tests code
xUnit Solution difficulties
Complex code constructions are hard to maintain
If it works don't touch it!
xUnit Solution difficulties
Low informative report
What exactly has happened?
We gonna make it better
How to improve it
We gonna make it better
It should be clear to everyone
We gonna make it better
More people should be involved
We gonna make it better
Profit
New approach?
Behavior-Driven Development?
How about tests like that?
Behavior description prior to implementation
List of BDD engines
Cucumber
Freshen
NBehave
JBehave
Behat
BDD tests structure
FeatureBackground
Scenario
Background
Scenario 1
Scenario 2
Scenario N
Given
When
Then
Given
When
Then
When I log into the system as “login”/”password”
When /log into the system as “(.*)”\/”(.*)”/ do |login,password|app.login( login , password )
end
class Appdef login( username , password )
# Some actionsend
end
Connections to code
Actual Code
Text instruction
Explicit Selenium calls
BDD project structure
Main working folder
Keyword implementations
Core library
Initialization module
Tests storage
What BDD brings?
Natural language instructions
I can get it!
What BDD brings?
Reports show steps to reproduce
I see where the problem occurs!
What BDD brings? Process optimization
On-demand runs
Writes user stories
BA
Test Automation pipeline
What BDD brings? Process optimization
Test Automation pipeline
On-demand runs
Write simple tests
Dev
What BDD brings? Process optimization
Test Automation pipeline
Analyze results
Designs tests
Tester
What BDD brings? Process optimization
Test Automation pipeline
Results analysis
Implementation & code maintenance
ATE
Who participates in automation?
Stages to framework migration
Decompose code by details level
Extract Selenium object and wrap it into global object
Wrap each function with appropriate keyword
Re-design existing tests
Framework decomposition
Business Functions level
Pages level
Core level
Explicit Selenium
calls
Explicit Selenium
calls
We care what we do only
We care where we are
We care how to do it
Framework re-organization to BDD
Code layer
Business Functions level
Pages level
Core levelGlobal Selenium Object
Code layer
Framework re-organization to BDDImplementation layer
BF level
Pages level
Core level
Tests layerBF level
Pages level
Core levelSelenium
When /click on “(.*)” element/ do |locator|selenium.click( locator )
end
selenium.click( locator );
When I click on “Test” element
Call Command
Stop
Start
Selenium place
Collect all resources
Initialize shell
Run instructions
Finalize execution
Generate report
Global Selenium Object
DefaultSelenium.new
selenium.stop()
selenium.start()
There’re still some questions
How to locate elements?
How to avoid duplicates?
How to storevalues? How to use
random data?
UI elements mapping. What for?
When I click on "//div[@id='some_div']/button[text()='Add']" button
When I click on "Add" button on "Home Page"
When I click on “Search" link
When I create “test.txt" file in “C:\\Temp” folder
When I create “test.txt" file in “%USERPROFILE%” folder
Which way is more reliable and informative?
UI elements mapping. How?
Page
Title
Name
Item
Alias
Locator
Examples:Ini file
XML file
UI Mapping. Trivial case
Text instruction:
When I click on the “Updates” link
Actual code:
selenium.click( “link=Updates” );
UI Mapping. Specific page
When I click on the “Apply Button” on the “Links Page”
Will look into this section
Explicit Selenium calls
Similar elements on different
pages
Will take this locator
Will click here:
selenium.click(“links_apply_btn”)
UI Mapping. Current page
Explicit Selenium calls
Similar elements on different
pages
When I click on the “Apply Button” element
Will find section with matching header
Will take this locator
Will click here:
selenium.click(“links_apply_btn”)
Will read current page title
Main challenges
Different keywords can do the same things
Examples:
When /click on the “(.*)” link/
When /click on “(.*)” link/
When /click on (.*) link/
Main challenges
Resolution:
Standards & Naming Conventions!!!
Trainings & Review!!!
Main challenges
After that:
Examples:
When /click on the “(.*)” link/ #Valid as conforms the rules
When /click on “(.*)” link/ #Invalid. Violates Rule #1
Rule #1: each field, element, page name should have “the” article
Main challenges
Too many keywords Resolution: organize keywords vocabulary
Main challenges
Data exchange between steps
Resolution: use external hash for data storage
“My Folder” field now contains actual path
Main challenges
Random data generation Resolution:
Is necessary?
Is needed?
Use explicit value
Do not pass a value
Pass alias
Yes
Yes
No
No
Questions?