SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
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>

Contenu connexe

Tendances

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
Yusuke Wada
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web framework
taggg
 
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
Erik Osterman
 

Tendances (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
 

En vedette

En vedette (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
 

Similaire à Selenium Sandwich Part 1: Data driven Selenium

Django’s nasal passage
Django’s nasal passageDjango’s nasal passage
Django’s nasal passage
Erik Rose
 
Intro To Moose
Intro To MooseIntro To Moose
Intro To Moose
cPanel
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnet
Vlad Maniak
 

Similaire à 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
 

Plus de Workhorse Computing

Plus 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
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
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
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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...
 
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
 
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...
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 

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>