SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Downloaden Sie, um offline zu lesen
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!

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
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
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 

Kürzlich hochgeladen (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
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 🔝✔️✔️
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
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
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 

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!