SlideShare a Scribd company logo
1 of 18
Download to read offline
Automated Web-UI Testing
with behave-manners
PyCon Ireland 2019
Panos Christeas
github.com/xrg/behave_manners
2
Who am I
●
Software Engineer (developer)
●
C, C++, PHP, Python (and more)
●
Focus on Quality of code, the “why”
●
Open source course
3
Testing shows the
presence, not the absence
of bugs
Edsger W. Dijkstra, 1969
github.com/xrg/behave_manners
4
Web UI need testing
●
Web UIs are all over the place
●
Nobody writes plain (nor clean) HTML
●
Complexity has exploded
(using React, Angular, Ember, etcJS)
●
Front face of product, functionality
●
They're alive!
github.com/xrg/behave_manners
5
Python to the rescue
Python is suitable for testing:
●
It is scripted
●
Easy, sugar-free syntax
●
Should be your choice for backend
●
Modular, easy to extend
github.com/xrg/behave_manners
6
Behave + ? + Selenium
Behave:
●
BDD, TDD, output formatting
+ parallel ;)
Selenium
●
Standard, industry choice
●
Defines WebDriver, all browsers support
But, middleware?
github.com/xrg/behave_manners
7
Example of Selenium on behave
@when('I enter my login details')
def enter_credentials(context):
context.driver.find_element_by_id('username').send_keys('test_user')
context.driver.find_element_by_id('password').send_keys('test123')
@when('I click login')
def click_login(context):
context.driver.find_element_by_xpath('/html/body/div/div/div/div/form/div[3]/button').click()
●
Doesn't scale well
●
DOM mixed with procedural code
●
Need to repeat XPaths all over; cannot test them until that step is called
●
Still broken for dynamic DOM
●
Same in other languages
github.com/xrg/behave_manners
8
Behave manners
●
Abstracts DOM into “components”
●
Assigns actions/methods to coms.
●
Nested model, reusable blocks
●
Split DOM parsing from step logic
●
Recursive abstraction
●
Configures browser, utilities
github.com/xrg/behave_manners
9
Manners architecture
<div>
<p>ActionChains:</p>
<div class= "highlight">
<pre><span class= "n">menu</span>= driver.find_element_by_css_selector(".nav")
</pre>
</div>
</div>
Target webpage DOM
<div this= "section">
<p>[title]</p>
<div class= "highlight" this= "content">
<pre>[text]
</pre>
</div>
</div>
Pagelem template DOM
Site settings
browser
base_url
site config
Page components
section
content
text="menu = driver.find..."
title="Action Chains:"
Gherkin scenario
When I visit the page
Then section title should be "Action Chains"
@then('section title should be "{expected}"')
def check_section_title(context, expected):
section = context.cur_page['section']
assert section.title == expected.rstrip(':')
Step implementation
Remote browser
Behave manners
Behave
Abstractionflow
Selenium API
github.com/xrg/behave_manners
10
Manners: page elements
●
HTML-like language to parse the site
●
abstract: write only as much as works
●
some advanced elements:
– repeat
– optional
– deep
– choice
●
emits “components” with “this”
github.com/xrg/behave_manners
11
Manners pagelems example
<html>
<body>
<div class="test-class" id="upload-area" this="upload-area">
<pe-choice>
<form this="form">
<input type="file" name="file">
<input type="submit" value="Upload" pe-name="submit">
</form>
<div class="upload-ok" this="ok">
The file has been uploaded:
</div>
<div class="payload" this="payload">
[text]
</div>
</pe-choice>
</div>
github.com/xrg/behave_manners
12
Manners: components
●
Python objects, mapped to remote DOM
●
Dictionaries, containing sub-components
●
Attributes from remote attributes (or const)
●
Lazy, volatile: cache them yourself
●
Suitable for behave step code
@then('I can count the lines of that table')
def count_table(context):
table = context.cur_page['content']['table']
len_rows = len(table['rows'])
if len_rows != context.num_rows:
raise CAssertionError("Table has %d rows" % len_rows, component=table)
github.com/xrg/behave_manners
13
First steps with behave-manners
●
Pick an environment (py2.7 is supported)
●
Install behave-manners
(note on behave==1.2.6 / parallel)
●
Install chromedriver (or geckodriver)
●
Setup initial project files
– environment.py
– config.yaml
– site/index.html
– site/some-page.html
– steps/first_steps.py
– first-test.feature
Run, rinse, repeat!
github.com/xrg/behave_manners
14
Manners: validator tool
●
Separates pagelems from step logic
●
Two parts: run-browser + validator
●
Repeat until template is correct
●
Interactive mode
github.com/xrg/behave_manners
15
Demo
github.com/xrg/behave_manners
16
Extra material: controllers
●
Assign methods to
components
●
Expose calculated
properties
●
Value setters, indirect
class MatInputFieldCtrl(DOMScope):
_name = "mat-input-field"
class Component(object):
@property
def value(self):
return self['input'].value
@value.setter
def value(self, val):
self['input'].value = val
@property
def error_message(self):
try:
return self['error'].message
except KeyError:
return None
class ChildComponent(object):
pass
github.com/xrg/behave_manners
17
PyCon
github.com/xrg/behave_manners
18
Where next?
●
Questions?
●
TYOP (test your own project)
●
Manners is still WIP
●
Documentation
https://behave-manners.readthedocs.io/
●
Grow, contribute
Thank you!

More Related Content

What's hot

Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web ApplicationsSeth McLaughlin
 
APIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsAPIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsSauce Labs
 
Test-Driven JavaScript Development (JavaZone 2010)
Test-Driven JavaScript Development (JavaZone 2010)Test-Driven JavaScript Development (JavaZone 2010)
Test-Driven JavaScript Development (JavaZone 2010)Christian Johansen
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Codemotion
 
Django rest framework tips and tricks
Django rest framework   tips and tricksDjango rest framework   tips and tricks
Django rest framework tips and tricksxordoquy
 
DevQA: make your testers happier with Groovy, Spock and Geb
DevQA: make your testers happier with Groovy, Spock and GebDevQA: make your testers happier with Groovy, Spock and Geb
DevQA: make your testers happier with Groovy, Spock and GebAlvaro Sanchez-Mariscal
 
AngularJS and Protractor
AngularJS and ProtractorAngularJS and Protractor
AngularJS and ProtractorFilipe Falcão
 
Front-end Automated Testing
Front-end Automated TestingFront-end Automated Testing
Front-end Automated TestingRuben Teijeiro
 
Web Performance Part 4 "Client-side performance"
Web Performance Part 4  "Client-side performance"Web Performance Part 4  "Client-side performance"
Web Performance Part 4 "Client-side performance"Binary Studio
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend TestingNeil Crosby
 
Acceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmAcceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmChristopher Bartling
 
Testing nightwatch, by David Torroija
Testing nightwatch, by David TorroijaTesting nightwatch, by David Torroija
Testing nightwatch, by David TorroijaDavid Torroija
 
Introduction To Web Application Testing
Introduction To Web Application TestingIntroduction To Web Application Testing
Introduction To Web Application TestingYnon Perek
 
Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)Adam Štipák
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVMAlan Parkinson
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: DemystifiedSeth McLaughlin
 

What's hot (20)

Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web Applications
 
APIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page ObjectsAPIs: A Better Alternative to Page Objects
APIs: A Better Alternative to Page Objects
 
Test-Driven JavaScript Development (JavaZone 2010)
Test-Driven JavaScript Development (JavaZone 2010)Test-Driven JavaScript Development (JavaZone 2010)
Test-Driven JavaScript Development (JavaZone 2010)
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
 
Django rest framework tips and tricks
Django rest framework   tips and tricksDjango rest framework   tips and tricks
Django rest framework tips and tricks
 
DevQA: make your testers happier with Groovy, Spock and Geb
DevQA: make your testers happier with Groovy, Spock and GebDevQA: make your testers happier with Groovy, Spock and Geb
DevQA: make your testers happier with Groovy, Spock and Geb
 
AngularJS and Protractor
AngularJS and ProtractorAngularJS and Protractor
AngularJS and Protractor
 
Front-end Automated Testing
Front-end Automated TestingFront-end Automated Testing
Front-end Automated Testing
 
Web Performance Part 4 "Client-side performance"
Web Performance Part 4  "Client-side performance"Web Performance Part 4  "Client-side performance"
Web Performance Part 4 "Client-side performance"
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend Testing
 
Testing in GO
Testing in GOTesting in GO
Testing in GO
 
Acceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmAcceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvm
 
Testing nightwatch, by David Torroija
Testing nightwatch, by David TorroijaTesting nightwatch, by David Torroija
Testing nightwatch, by David Torroija
 
Continuous feature-development
Continuous feature-developmentContinuous feature-development
Continuous feature-development
 
Introduction To Web Application Testing
Introduction To Web Application TestingIntroduction To Web Application Testing
Introduction To Web Application Testing
 
DDD with Behat
DDD with BehatDDD with Behat
DDD with Behat
 
Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVM
 
Night Watch with QA
Night Watch with QANight Watch with QA
Night Watch with QA
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: Demystified
 

Similar to Behave manners for ui testing pycon2019

Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHPMarcos Quesada
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersJavan Rasokat
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patternsStoyan Stefanov
 
JavaScript Performance Patterns
JavaScript Performance PatternsJavaScript Performance Patterns
JavaScript Performance PatternsStoyan Stefanov
 
Mastering selenium for automated acceptance tests
Mastering selenium for automated acceptance testsMastering selenium for automated acceptance tests
Mastering selenium for automated acceptance testsNick Belhomme
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsLeticia Rss
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a bossFrancisco Ribeiro
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework BasicMario Romano
 
Make BDD great again
Make BDD great againMake BDD great again
Make BDD great againYana Gusti
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testingMats Bryntse
 
Selenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaSelenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaEr. Sndp Srda
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsOWASP Kyiv
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsAbhijeet Vaikar
 
C++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroC++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroMohammad Shaker
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
Node.js Development Workflow Automation with Grunt.js
Node.js Development Workflow Automation with Grunt.jsNode.js Development Workflow Automation with Grunt.js
Node.js Development Workflow Automation with Grunt.jskiyanwang
 

Similar to Behave manners for ui testing pycon2019 (20)

Selenium
SeleniumSelenium
Selenium
 
Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHP
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
 
JavaScript Performance Patterns
JavaScript Performance PatternsJavaScript Performance Patterns
JavaScript Performance Patterns
 
Mastering selenium for automated acceptance tests
Mastering selenium for automated acceptance testsMastering selenium for automated acceptance tests
Mastering selenium for automated acceptance tests
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjects
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
 
Make BDD great again
Make BDD great againMake BDD great again
Make BDD great again
 
ASP.NET - Ivan Marković
ASP.NET - Ivan MarkovićASP.NET - Ivan Marković
ASP.NET - Ivan Marković
 
Selenium testing - Handle Elements in WebDriver
Selenium testing - Handle Elements in WebDriver Selenium testing - Handle Elements in WebDriver
Selenium testing - Handle Elements in WebDriver
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testing
 
Selenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaSelenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep Sharda
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
 
C++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroC++ Windows Forms L01 - Intro
C++ Windows Forms L01 - Intro
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Node.js Development Workflow Automation with Grunt.js
Node.js Development Workflow Automation with Grunt.jsNode.js Development Workflow Automation with Grunt.js
Node.js Development Workflow Automation with Grunt.js
 

Recently uploaded

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile EnvironmentVictorSzoltysek
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 

Recently uploaded (20)

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 

Behave manners for ui testing pycon2019

  • 1. Automated Web-UI Testing with behave-manners PyCon Ireland 2019 Panos Christeas
  • 2. github.com/xrg/behave_manners 2 Who am I ● Software Engineer (developer) ● C, C++, PHP, Python (and more) ● Focus on Quality of code, the “why” ● Open source course
  • 3. 3 Testing shows the presence, not the absence of bugs Edsger W. Dijkstra, 1969
  • 4. github.com/xrg/behave_manners 4 Web UI need testing ● Web UIs are all over the place ● Nobody writes plain (nor clean) HTML ● Complexity has exploded (using React, Angular, Ember, etcJS) ● Front face of product, functionality ● They're alive!
  • 5. github.com/xrg/behave_manners 5 Python to the rescue Python is suitable for testing: ● It is scripted ● Easy, sugar-free syntax ● Should be your choice for backend ● Modular, easy to extend
  • 6. github.com/xrg/behave_manners 6 Behave + ? + Selenium Behave: ● BDD, TDD, output formatting + parallel ;) Selenium ● Standard, industry choice ● Defines WebDriver, all browsers support But, middleware?
  • 7. github.com/xrg/behave_manners 7 Example of Selenium on behave @when('I enter my login details') def enter_credentials(context): context.driver.find_element_by_id('username').send_keys('test_user') context.driver.find_element_by_id('password').send_keys('test123') @when('I click login') def click_login(context): context.driver.find_element_by_xpath('/html/body/div/div/div/div/form/div[3]/button').click() ● Doesn't scale well ● DOM mixed with procedural code ● Need to repeat XPaths all over; cannot test them until that step is called ● Still broken for dynamic DOM ● Same in other languages
  • 8. github.com/xrg/behave_manners 8 Behave manners ● Abstracts DOM into “components” ● Assigns actions/methods to coms. ● Nested model, reusable blocks ● Split DOM parsing from step logic ● Recursive abstraction ● Configures browser, utilities
  • 9. github.com/xrg/behave_manners 9 Manners architecture <div> <p>ActionChains:</p> <div class= "highlight"> <pre><span class= "n">menu</span>= driver.find_element_by_css_selector(".nav") </pre> </div> </div> Target webpage DOM <div this= "section"> <p>[title]</p> <div class= "highlight" this= "content"> <pre>[text] </pre> </div> </div> Pagelem template DOM Site settings browser base_url site config Page components section content text="menu = driver.find..." title="Action Chains:" Gherkin scenario When I visit the page Then section title should be "Action Chains" @then('section title should be "{expected}"') def check_section_title(context, expected): section = context.cur_page['section'] assert section.title == expected.rstrip(':') Step implementation Remote browser Behave manners Behave Abstractionflow Selenium API
  • 10. github.com/xrg/behave_manners 10 Manners: page elements ● HTML-like language to parse the site ● abstract: write only as much as works ● some advanced elements: – repeat – optional – deep – choice ● emits “components” with “this”
  • 11. github.com/xrg/behave_manners 11 Manners pagelems example <html> <body> <div class="test-class" id="upload-area" this="upload-area"> <pe-choice> <form this="form"> <input type="file" name="file"> <input type="submit" value="Upload" pe-name="submit"> </form> <div class="upload-ok" this="ok"> The file has been uploaded: </div> <div class="payload" this="payload"> [text] </div> </pe-choice> </div>
  • 12. github.com/xrg/behave_manners 12 Manners: components ● Python objects, mapped to remote DOM ● Dictionaries, containing sub-components ● Attributes from remote attributes (or const) ● Lazy, volatile: cache them yourself ● Suitable for behave step code @then('I can count the lines of that table') def count_table(context): table = context.cur_page['content']['table'] len_rows = len(table['rows']) if len_rows != context.num_rows: raise CAssertionError("Table has %d rows" % len_rows, component=table)
  • 13. github.com/xrg/behave_manners 13 First steps with behave-manners ● Pick an environment (py2.7 is supported) ● Install behave-manners (note on behave==1.2.6 / parallel) ● Install chromedriver (or geckodriver) ● Setup initial project files – environment.py – config.yaml – site/index.html – site/some-page.html – steps/first_steps.py – first-test.feature Run, rinse, repeat!
  • 14. github.com/xrg/behave_manners 14 Manners: validator tool ● Separates pagelems from step logic ● Two parts: run-browser + validator ● Repeat until template is correct ● Interactive mode
  • 16. github.com/xrg/behave_manners 16 Extra material: controllers ● Assign methods to components ● Expose calculated properties ● Value setters, indirect class MatInputFieldCtrl(DOMScope): _name = "mat-input-field" class Component(object): @property def value(self): return self['input'].value @value.setter def value(self, val): self['input'].value = val @property def error_message(self): try: return self['error'].message except KeyError: return None class ChildComponent(object): pass
  • 18. github.com/xrg/behave_manners 18 Where next? ● Questions? ● TYOP (test your own project) ● Manners is still WIP ● Documentation https://behave-manners.readthedocs.io/ ● Grow, contribute Thank you!