SlideShare uma empresa Scribd logo
1 de 30
Baixar para ler offline
Selenium Sandwich Part 1:
Automating Selenium Sequences
Steven Lembark
Workhorse Computing
lembark@wrkhors.com
Testing web front ends is different
Much of the testing is manual.
Tests validate multiple systems at once.
Often cannot test without a running back end.
Here is the first installment of a better way.
Been there?
Hey where did that come from? Check the
logs...
Can't use that database: dropped it last
week...
Server isn't using your version any more...
Q: Why is it this bad?
A: Because you aren't testing the front end.
Q: Why is it this bad?
A: Because you aren't testing the front end.
Q: Where do you get the content for testing?
Q: Why is it this bad?
A: Because you aren't testing the front end.
Q: Where do you get the content for testing?
A: The back end.
Q: Why is it this bad?
A: Because you aren't testing the front end.
Q: Where do you get the content for testing?
A: The back end.
You are testing both ends at once.
Q: Why is it this bad?
A: Because you aren't testing the front end.
Q: Where do you get the content for testing?
A: The back end.
You are testing both ends at once.
That makes front ends different.
Testing just the front end
Isolation and repeatiblity are key to testing.
Selenium helps with repeatability.
Catch: Hardwired code required for each test.
Example Selenium::Driver code
Q: Is there a better way?
A: Data driven code.
With Object::Exercise code like:
$object->method( @argz )->...
Becomes
[ $method => @argz ], ...
Daisy-chain logic
find_element returns an object:
$driver->find_element( ... )->click;
$driver
->find_element( ... )
->send_keys( ... )
->send_keys( KEY->{ enter } );
False Lazyness
Calls to “find_element” use the element.
Hardwiring multiple calls is extra work.
Why not “find_and_click”, “find_and_type”?
A: Selenium interface doesn't declare them.
Q: Why can't we do better than the interface?
True Lazyness
Adding high-level abstractions is easy.
Wrap the object.
Add an AUTOLOAD.
Redispatch low-level calls.
Selenium::Easy
What would you use for a wrapper object?
Selenium::Easy
What would you use for a wrapper object?
Usual suggestion:
{ wrapped => $object }
Selenium::Easy
What would you use for a wrapper object?
Usual suggestion:
{ wrapped => $object }
Downsides: Bulky, Slow, Klutzy->{ syntax }
Simpler wrapper
sub construct
{
my $proto = shift;
bless
( my $obj = '' ),
blessed $proto || $proto
}
Simpler packaging
sub initialize
{
state $pkg
= 'Remote::Selenium::Driver';
my $wrapper = shift;
$$wrapper = $pkg->new( @_ );
$wrapper
}
High-level methods
sub find_and_key
{
my ( $wrapper, $find ) = splice @_,0,2;
my $found
= $$wrapper->find_element( @$find );
$found->send_key( $_ )
for @_, KEYS->{ enter };
}
High-level methods
Dispatching low-level methods
our $AUTOLOAD = '';
AUTOLOAD
{
my $wrapper = shift;
my $i = 1 + rindex $AUTOLOAD, ':';
my $name = substr $AUTOLOAD, $i;
$$wrapper->$name( @_ )
}
Q: Why not just drive a new class?
A: Avoid knowing base class structure.
AUTOLOAD and $$wrapper
have no idea what the wrapped object is.
Replacing custom code
Daisy chains now become single-steps:
$wrapper->find_and_key( ... );
$wrapper->find_and_click( ... );
Replacing custom code
Passed to Object::Exercise as:
$wrapper->$exercise
(
[ [ find_and_key => ... ], ... ],
[ [ find_and_click => ... ], ... ],
);
Replacing custom code
Or with YAML like:
---
-
- - find_and_key
- ...
-
- - find_and_click
- ...
Data-driven equivalent
# use Object::Exercise;
# $wrapper->$exercise( $yaml );
---
-
# verbose speicfic to "prepare_test" block.
# prepare test ignores return values.
- verbose
- - prepare_test
- - set_implicit_wait_timeout
- 50000
- - get
- http://www.google.com
-
- - find_send_keys
- - q
- name
- YAPC Salt Lake City
-
- - find_click
- '#rso li h3 a'
- css
Data-driven equivalent
-
- regex
- - get_title
- YAPC
- Title includes 'YAPC'
-
- - find_click
- Talks and Schedule
-
- - find_click
- Schedule
-
- - find_click
- Wednesday
-
- - find_click
- Selenium
- partial_link_text
-
- regex
- - get_title
- Selenium
- Title includes 'Selenium'
So ends our first episode...
Developing wrapper classes in Perl is trivial.
Repeatable test metadata is simple enough:
Use high-level calls with Selenium.
Coming up next: Isolating the front end.
=head1 SEE ALSO
Good general talk on Selenium.
Introduces the Selenium Playground on
github:
<http://www.slidesearchengine.com/slide/
testing-your-website-with-selenium-perl>
=head1 SEE ALSO
Overview of Object::Exercise
<http://www.slideshare.net/lembark/object-
exercise?qid=6ed2ecf1-2520-4d4a-b6fa-
545b95693ebc&v=qf1&b=&from_search=1>
Current documentation:
<http://search.cpan.org/~lembark/Object-
Exercise-3.02/lib/Object/Exercise.pm>

Mais conteúdo relacionado

Mais procurados

Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with CucumberBen Mabey
 
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTERSINATRA + HAML + TWITTER
SINATRA + HAML + TWITTERElber Ribeiro
 
Entry-level PHP for WordPress
Entry-level PHP for WordPressEntry-level PHP for WordPress
Entry-level PHP for WordPresssprclldr
 
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...andrewnacin
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011andrewnacin
 
Build a bot workshop async primer - php[tek]
Build a bot workshop  async primer - php[tek]Build a bot workshop  async primer - php[tek]
Build a bot workshop async primer - php[tek]Adam Englander
 
IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009Yusuke Wada
 
A reviravolta do desenvolvimento web
A reviravolta do desenvolvimento webA reviravolta do desenvolvimento web
A reviravolta do desenvolvimento webWallace Reis
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWP Engine UK
 
Cucumber Ru09 Web
Cucumber Ru09 WebCucumber Ru09 Web
Cucumber Ru09 WebJoseph Wilk
 
Django REST Framework
Django REST FrameworkDjango REST Framework
Django REST FrameworkLoad Impact
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web frameworktaggg
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with RubyKeith Pitty
 
Speeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue ServerSpeeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue ServerErik Osterman
 

Mais procurados (19)

Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
Cucumber testing
Cucumber testingCucumber testing
Cucumber testing
 
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTERSINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
 
Entry-level PHP for WordPress
Entry-level PHP for WordPressEntry-level PHP for WordPress
Entry-level PHP for WordPress
 
Mojolicious on Steroids
Mojolicious on SteroidsMojolicious on Steroids
Mojolicious on Steroids
 
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011
 
Build a bot workshop async primer - php[tek]
Build a bot workshop  async primer - php[tek]Build a bot workshop  async primer - php[tek]
Build a bot workshop async primer - php[tek]
 
IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009IRC HTTP Stream in YAPC::Asia 2009
IRC HTTP Stream in YAPC::Asia 2009
 
Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
 
A reviravolta do desenvolvimento web
A reviravolta do desenvolvimento webA reviravolta do desenvolvimento web
A reviravolta do desenvolvimento web
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
 
Cucumber Ru09 Web
Cucumber Ru09 WebCucumber Ru09 Web
Cucumber Ru09 Web
 
BDD with cucumber
BDD with cucumberBDD with cucumber
BDD with cucumber
 
Django REST Framework
Django REST FrameworkDjango REST Framework
Django REST Framework
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web framework
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with Ruby
 
GAEO
GAEOGAEO
GAEO
 
Speeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue ServerSpeeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue Server
 

Destaque

Destaque (12)

Kazantseva
KazantsevaKazantseva
Kazantseva
 
Presentation1
Presentation1Presentation1
Presentation1
 
My cv 016
My cv 016My cv 016
My cv 016
 
Presentation1
Presentation1Presentation1
Presentation1
 
certificate
certificatecertificate
certificate
 
Feldman Feldman & Associates Pc
Feldman Feldman & Associates PcFeldman Feldman & Associates Pc
Feldman Feldman & Associates Pc
 
Koss
KossKoss
Koss
 
Feldman Feldman & Associates PC
Feldman Feldman & Associates PCFeldman Feldman & Associates PC
Feldman Feldman & Associates PC
 
Feldman Feldman & Associates PC
Feldman Feldman & Associates PCFeldman Feldman & Associates PC
Feldman Feldman & Associates PC
 
Feldman Feldman & Associates
Feldman Feldman & AssociatesFeldman Feldman & Associates
Feldman Feldman & Associates
 
Lido del faro competenze 2015
Lido del faro competenze 2015Lido del faro competenze 2015
Lido del faro competenze 2015
 
Presentation app
Presentation appPresentation app
Presentation app
 

Semelhante a Selenium Sandwich Part 1: Data driven Selenium

Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Workhorse Computing
 
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.Workhorse Computing
 
Django’s nasal passage
Django’s nasal passageDjango’s nasal passage
Django’s nasal passageErik Rose
 
Test automation with selenide
Test automation with selenideTest automation with selenide
Test automation with selenideIsuru Madanayaka
 
Intro To Moose
Intro To MooseIntro To Moose
Intro To MoosecPanel
 
Perl Teach-In (part 2)
Perl Teach-In (part 2)Perl Teach-In (part 2)
Perl Teach-In (part 2)Dave Cross
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)andrewnacin
 
Token Testing Slides
Token  Testing SlidesToken  Testing Slides
Token Testing Slidesericholscher
 
Functional Javascript
Functional JavascriptFunctional Javascript
Functional Javascriptguest4d57e6
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everythingnoelrap
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnetVlad Maniak
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJSPeter Drinnan
 
O CPAN tem as ferramentas que você precisa para fazer TDD em Perl, o Coding D...
O CPAN tem as ferramentas que você precisa para fazer TDD em Perl, o Coding D...O CPAN tem as ferramentas que você precisa para fazer TDD em Perl, o Coding D...
O CPAN tem as ferramentas que você precisa para fazer TDD em Perl, o Coding D...Rodolfo Carvalho
 
New Ideas for Old Code - Greach
New Ideas for Old Code - GreachNew Ideas for Old Code - Greach
New Ideas for Old Code - GreachHamletDRC
 
Escape from the automation hell
Escape from the automation hellEscape from the automation hell
Escape from the automation hellNikita Simonovets
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend TestingNeil Crosby
 
Flaky No More: Find the Right Framework for Your Selenium Tests
Flaky No More: Find the Right Framework for Your Selenium TestsFlaky No More: Find the Right Framework for Your Selenium Tests
Flaky No More: Find the Right Framework for Your Selenium TestsTechWell
 
Testing in Laravel
Testing in LaravelTesting in Laravel
Testing in LaravelAhmed Yahia
 

Semelhante a Selenium Sandwich Part 1: Data driven Selenium (20)

Unit Testing Lots of Perl
Unit Testing Lots of PerlUnit Testing Lots of Perl
Unit Testing Lots of Perl
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.
 
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.
 
Django’s nasal passage
Django’s nasal passageDjango’s nasal passage
Django’s nasal passage
 
Test automation with selenide
Test automation with selenideTest automation with selenide
Test automation with selenide
 
Intro To Moose
Intro To MooseIntro To Moose
Intro To Moose
 
Perl Teach-In (part 2)
Perl Teach-In (part 2)Perl Teach-In (part 2)
Perl Teach-In (part 2)
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)
 
Token Testing Slides
Token  Testing SlidesToken  Testing Slides
Token Testing Slides
 
Functional Javascript
Functional JavascriptFunctional Javascript
Functional Javascript
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everything
 
Ling framework
Ling frameworkLing framework
Ling framework
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnet
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
 
O CPAN tem as ferramentas que você precisa para fazer TDD em Perl, o Coding D...
O CPAN tem as ferramentas que você precisa para fazer TDD em Perl, o Coding D...O CPAN tem as ferramentas que você precisa para fazer TDD em Perl, o Coding D...
O CPAN tem as ferramentas que você precisa para fazer TDD em Perl, o Coding D...
 
New Ideas for Old Code - Greach
New Ideas for Old Code - GreachNew Ideas for Old Code - Greach
New Ideas for Old Code - Greach
 
Escape from the automation hell
Escape from the automation hellEscape from the automation hell
Escape from the automation hell
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend Testing
 
Flaky No More: Find the Right Framework for Your Selenium Tests
Flaky No More: Find the Right Framework for Your Selenium TestsFlaky No More: Find the Right Framework for Your Selenium Tests
Flaky No More: Find the Right Framework for Your Selenium Tests
 
Testing in Laravel
Testing in LaravelTesting in Laravel
Testing in Laravel
 

Mais de Workhorse Computing

Wheels we didn't re-invent: Perl's Utility Modules
Wheels we didn't re-invent: Perl's Utility ModulesWheels we didn't re-invent: Perl's Utility Modules
Wheels we didn't re-invent: Perl's Utility ModulesWorkhorse Computing
 
Paranormal statistics: Counting What Doesn't Add Up
Paranormal statistics: Counting What Doesn't Add UpParanormal statistics: Counting What Doesn't Add Up
Paranormal statistics: Counting What Doesn't Add UpWorkhorse Computing
 
Generating & Querying Calendar Tables in Posgresql
Generating & Querying Calendar Tables in PosgresqlGenerating & Querying Calendar Tables in Posgresql
Generating & Querying Calendar Tables in PosgresqlWorkhorse Computing
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Workhorse Computing
 
BSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationBSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationWorkhorse Computing
 
BASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic InterpolationBASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic InterpolationWorkhorse Computing
 
The W-curve and its application.
The W-curve and its application.The W-curve and its application.
The W-curve and its application.Workhorse Computing
 
Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.Workhorse Computing
 
Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Workhorse Computing
 
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Workhorse Computing
 

Mais de Workhorse Computing (20)

Wheels we didn't re-invent: Perl's Utility Modules
Wheels we didn't re-invent: Perl's Utility ModulesWheels we didn't re-invent: Perl's Utility Modules
Wheels we didn't re-invent: Perl's Utility Modules
 
mro-every.pdf
mro-every.pdfmro-every.pdf
mro-every.pdf
 
Paranormal statistics: Counting What Doesn't Add Up
Paranormal statistics: Counting What Doesn't Add UpParanormal statistics: Counting What Doesn't Add Up
Paranormal statistics: Counting What Doesn't Add Up
 
Generating & Querying Calendar Tables in Posgresql
Generating & Querying Calendar Tables in PosgresqlGenerating & Querying Calendar Tables in Posgresql
Generating & Querying Calendar Tables in Posgresql
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!
 
BSDM with BASH: Command Interpolation
BSDM with BASH: Command InterpolationBSDM with BASH: Command Interpolation
BSDM with BASH: Command Interpolation
 
Findbin libs
Findbin libsFindbin libs
Findbin libs
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
 
BASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic InterpolationBASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic Interpolation
 
Effective Benchmarks
Effective BenchmarksEffective Benchmarks
Effective Benchmarks
 
Metadata-driven Testing
Metadata-driven TestingMetadata-driven Testing
Metadata-driven Testing
 
The W-curve and its application.
The W-curve and its application.The W-curve and its application.
The W-curve and its application.
 
Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.Keeping objects healthy with Object::Exercise.
Keeping objects healthy with Object::Exercise.
 
Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.
 
Smoking docker
Smoking dockerSmoking docker
Smoking docker
 
Getting Testy With Perl6
Getting Testy With Perl6Getting Testy With Perl6
Getting Testy With Perl6
 
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
 
Neatly folding-a-tree
Neatly folding-a-treeNeatly folding-a-tree
Neatly folding-a-tree
 
Light my-fuse
Light my-fuseLight my-fuse
Light my-fuse
 
Paranormal stats
Paranormal statsParanormal stats
Paranormal stats
 

Último

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Último (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Selenium Sandwich Part 1: Data driven Selenium

  • 1. Selenium Sandwich Part 1: Automating Selenium Sequences Steven Lembark Workhorse Computing lembark@wrkhors.com
  • 2. Testing web front ends is different Much of the testing is manual. Tests validate multiple systems at once. Often cannot test without a running back end. Here is the first installment of a better way.
  • 3. Been there? Hey where did that come from? Check the logs... Can't use that database: dropped it last week... Server isn't using your version any more...
  • 4. Q: Why is it this bad? A: Because you aren't testing the front end.
  • 5. Q: Why is it this bad? A: Because you aren't testing the front end. Q: Where do you get the content for testing?
  • 6. Q: Why is it this bad? A: Because you aren't testing the front end. Q: Where do you get the content for testing? A: The back end.
  • 7. Q: Why is it this bad? A: Because you aren't testing the front end. Q: Where do you get the content for testing? A: The back end. You are testing both ends at once.
  • 8. Q: Why is it this bad? A: Because you aren't testing the front end. Q: Where do you get the content for testing? A: The back end. You are testing both ends at once. That makes front ends different.
  • 9. Testing just the front end Isolation and repeatiblity are key to testing. Selenium helps with repeatability. Catch: Hardwired code required for each test.
  • 11. Q: Is there a better way? A: Data driven code. With Object::Exercise code like: $object->method( @argz )->... Becomes [ $method => @argz ], ...
  • 12. Daisy-chain logic find_element returns an object: $driver->find_element( ... )->click; $driver ->find_element( ... ) ->send_keys( ... ) ->send_keys( KEY->{ enter } );
  • 13. False Lazyness Calls to “find_element” use the element. Hardwiring multiple calls is extra work. Why not “find_and_click”, “find_and_type”? A: Selenium interface doesn't declare them. Q: Why can't we do better than the interface?
  • 14. True Lazyness Adding high-level abstractions is easy. Wrap the object. Add an AUTOLOAD. Redispatch low-level calls.
  • 15. Selenium::Easy What would you use for a wrapper object?
  • 16. Selenium::Easy What would you use for a wrapper object? Usual suggestion: { wrapped => $object }
  • 17. Selenium::Easy What would you use for a wrapper object? Usual suggestion: { wrapped => $object } Downsides: Bulky, Slow, Klutzy->{ syntax }
  • 18. Simpler wrapper sub construct { my $proto = shift; bless ( my $obj = '' ), blessed $proto || $proto }
  • 19. Simpler packaging sub initialize { state $pkg = 'Remote::Selenium::Driver'; my $wrapper = shift; $$wrapper = $pkg->new( @_ ); $wrapper }
  • 20. High-level methods sub find_and_key { my ( $wrapper, $find ) = splice @_,0,2; my $found = $$wrapper->find_element( @$find ); $found->send_key( $_ ) for @_, KEYS->{ enter }; } High-level methods
  • 21. Dispatching low-level methods our $AUTOLOAD = ''; AUTOLOAD { my $wrapper = shift; my $i = 1 + rindex $AUTOLOAD, ':'; my $name = substr $AUTOLOAD, $i; $$wrapper->$name( @_ ) }
  • 22. Q: Why not just drive a new class? A: Avoid knowing base class structure. AUTOLOAD and $$wrapper have no idea what the wrapped object is.
  • 23. Replacing custom code Daisy chains now become single-steps: $wrapper->find_and_key( ... ); $wrapper->find_and_click( ... );
  • 24. Replacing custom code Passed to Object::Exercise as: $wrapper->$exercise ( [ [ find_and_key => ... ], ... ], [ [ find_and_click => ... ], ... ], );
  • 25. Replacing custom code Or with YAML like: --- - - - find_and_key - ... - - - find_and_click - ...
  • 26. Data-driven equivalent # use Object::Exercise; # $wrapper->$exercise( $yaml ); --- - # verbose speicfic to "prepare_test" block. # prepare test ignores return values. - verbose - - prepare_test - - set_implicit_wait_timeout - 50000 - - get - http://www.google.com - - - find_send_keys - - q - name - YAPC Salt Lake City - - - find_click - '#rso li h3 a' - css
  • 27. Data-driven equivalent - - regex - - get_title - YAPC - Title includes 'YAPC' - - - find_click - Talks and Schedule - - - find_click - Schedule - - - find_click - Wednesday - - - find_click - Selenium - partial_link_text - - regex - - get_title - Selenium - Title includes 'Selenium'
  • 28. So ends our first episode... Developing wrapper classes in Perl is trivial. Repeatable test metadata is simple enough: Use high-level calls with Selenium. Coming up next: Isolating the front end.
  • 29. =head1 SEE ALSO Good general talk on Selenium. Introduces the Selenium Playground on github: <http://www.slidesearchengine.com/slide/ testing-your-website-with-selenium-perl>
  • 30. =head1 SEE ALSO Overview of Object::Exercise <http://www.slideshare.net/lembark/object- exercise?qid=6ed2ecf1-2520-4d4a-b6fa- 545b95693ebc&v=qf1&b=&from_search=1> Current documentation: <http://search.cpan.org/~lembark/Object- Exercise-3.02/lib/Object/Exercise.pm>