SlideShare ist ein Scribd-Unternehmen logo
1 von 55
Page Object From the Ground Up
Joseph Beale
02/07/2017
Agenda
1. Prepare the Environment
2.Build Automated Test using Watir
3.Convert to Page Object
4.Final Test Run
5.Q&A and Fun Time
But first...
Could I have a volunteer from the audience?
Environment
Create a folder called “test_project” under
c:rubyprograms
Environment
Inside of test_project, create a folder called
“features”. Then inside of that, create three
more called “step_definitions”, “support”,
and “pages”.
Environment
Open up the features -> support folder and
create a new text file called “env.rb”.
Environment
This demonstration will require you to have
Ruby installed on your system. For this, go
to https://rubyinstaller.org/ and download
the necessary installer. Then follow the
directions there.
After installing Ruby, grab the Cucumber
gem by typing “gem install cucumber” at a
command prompt.
Environment
We will need two more gems for this
demonstration:
• rspec
• page-object
Q: What is a Ruby gem?
A: A pre-built code module that performs
some useful function in Ruby, available for
free from https://rubygems.org
Environment
Open up env.rb using Notepad++ (free
download) and add the following
statements:
Require statements tell Ruby that you are
going to use some extra code modules.
Build
Create a feature file and a test scenario:
Cucumber scenarios are written in ordinary
business language using Gherkin
keywords (“Feature:”, “Scenario:”, “Given”,
“When”, “Then”, “And”, “But”).
Build
Optional: Create a batch file to execute
your test.
Build
These commands tell the operating system
to:
1.Open up a new command prompt in the
current directory
(c:rubyprogramstest_project).
2.Execute the “cucumber” command
3.Create a new report called “report.html”
and format it as an html document.
4.Open up the report.
Build
You can go ahead and run the test with no
other effort. It will not do much, but
Cucumber will give you a head start:
Build
Create a file called “my_steps.rb” in the
step_definitions folder and paste the
helper code snippets there:
Build
First step:
Given I am on the Bing home page
To satisfy this step, we need to open a
browser and navigate to the Bing home
page.
How do we do this in Ruby?
Build using Watir
Source: https://watir.github.io/
Build using Watir
Right on the front page is the code we
need to create a browser object (along
with lots of other helpful code):
We will use these exact lines of code but
modify them for our purposes.
Build using Watir
We will create “$browser” using the code
they gave us, but we will put it in the
env.rb file so that it is created before any
of the steps are run:
Build using Watir
Q: Why did you put a ‘$’ in front of your object
name?
A: To indicate that it is a global variable.
We want the browser object to be accessible
to all steps, so we make it global.
Build using Watir
In the first step definition, we will put the
next line of code, but modified to reflect
our global browser object and the URL for
Bing.com:
Now when we run our test we will get...
Build using Watir
...the Bing home page!
Build using Watir
Note that our report now shows one step is
green, meaning that it has passed:
Build using Watir
A quick word about method calls: the
format for calling a method in Ruby is
(object name) + dot (‘.’) + (method name).
So in the method call below, the object
name is ‘$browser’ and the method name
is ‘goto’.
Build using Watir
The ‘goto’ method is just one of the pre-
defined methods inside of the Watir::Browser
class. The method takes one argument: a
URL (because it needs to know where to “go
to”).
Arguments can be passed either inside of
parentheses or alongside a method call. So
in the previous example we could have said:
$browser.goto(‘bing.com’)
Build using Watir
Second step:
When I search the phrase "Call me Ishmael"
To automate this step, we need to interact
with two elements on the page:
1. The search text field
2. The search button (indicated by the
magnifying glass icon).
Build using Watir
Watir has several methods in the Browser
class to interact with the elements that are
common to most web pages. The two we
need are listed in the example given on their
home page (right under the ‘goto’):
Build using Watir
To interact with the two search elements, we
will use the ‘text_field’ and ‘button’ methods.
These two methods each take one argument:
a locator as indicated by the syntax (locator:
‘unique_identifier’).
For example:
$browser.text_field(id: ‘my_id’).set ‘my text’
$browser.button(id: ‘my_button’).click
Build using Watir
The locators are part of the page’s
Document Object Model or DOM, which is
a model of the page’s html code. But you
don’t need to understand the underlying
code; all you need to know is how to
inspect your desired elements.
Build using Watir
If you are using Chrome browser, you can
activate DevTools in three ways:
Source:
https://developers.google.com/web/tools/chrome-devtools/
Build using Watir
Inspecting the search box yields:
Build using Watir
The most common locator to use is ‘id’, so
we will copy the value for the id locator
(“sb_form_q”) and use it in our code for
the text_field method.
Build using Watir
Once nice feature of Ruby method calls is the
ability to “chain” methods one right after
another. Ruby will execute them in the order
given, from left to right. That is what you see
in the text_field example:
The ‘set’ method is executed right after the
text_field method.
Build using Watir
You can use the ‘set’ method anytime you
have defined a text field element using the
‘text_field’ method. It takes one argument: the
word or phrase that you wish to place in the
field. So, substituting a helpful variable name
like “search_phrase” for “arg1” in the code
snippet, the code for our second step looks
like this:
Build using Watir
Q: Where does the value for
“search_phrase” come from?
A: It is passed into the code from the
Gherkin step using a capture group.
This cryptic bit of code "([^"]*)" grabs
whatever is between the double-quotes
and throws it into my given variable.
Build using Watir
Since the variable search_phrase is a string,
we can use it as an argument for the set
method. And so then we are able to use that
same Ruby code block no matter what
phrase is used in the Gherkin.
Step →
Step definition →
Build using Watir
Now running the test yields:
For the button element, we’ll do it exactly
like we did the text field except that
instead of using the set method we will
need to find a method that will click the
button. The method name in this case is -
surprise! - click. From the Watir site:
browser.button(type: 'submit').click
Build using Watir
For most buttons, the locator they are using
(type: ‘submit’) will work but it’s not
specific enough so we’ll use the id to
locate the field. Adding that and the dollar
sign for the global variable, our step
definition looks like this:
Build using Watir
Running again we get:
Build using Watir
And in the report two steps are now green:
Build using Watir
Third step:
Then I will see results that contain “Moby
Dick”
Somehow we need to get our code to
examine the result page and check to see
if our phrase “Moby Dick” is found
anywhere. This is where the RSpec gem
comes in handy.
Build using Watir
There are many different ways to compare
fields using RSpec, but the one we will use
is a combination of “should” and “include”.
To locate the results area, we found that
we can use the ‘div’ method and an id of
‘b_content’.
Build using Watir
Running again causes all steps to pass:
Why Page Object
The Problem: If you have multiple tests or
even multiple steps that use the same
page elements, it’s tedious to keep having
to locate them by id again and again.
The Solution: Store all of the attributes for
any given page in one place, assign them
labels, and then in your steps simply refer
to the pages and the labels.
Convert to Page Object
The Page Object gem requires some
additional lines of code in the env.rb file:
Hint: code it and forget it.
Convert to Page Object
For each page where we need to interact
with fields or other attributes, we will need
to create a class (blueprint for an object):
Convert to Page Object
When we create a class to represent a
page, we are creating a situation where
the attributes of the page are already
defined and they are just waiting for the
page object to be instantiated by creating
a new instance of the class. Once that is
done, the user has access to all of the
attribute methods.
Convert to Page Object
Digging into the code for the two page
classes:
Convert to Page Object
Q: Why use ‘include’?
A: This will pull all of the standard Page
Object methods into your class.
http://www.rubydoc.info/github/cheezy/page-object/PageObject/Accessors
Convert to Page Object
For example:
Convert to Page Object
Here is what our steps will look like:
Convert to Page Object
Special Page Object Methods
visit - grabs the URL passed to the
‘page_url’ method and executes a ‘goto’
method on it.
on_page or on - instantiates the named
page and allows you to access its
attributes and their methods.
Final Test Run
Running again, we see the steps are still
green:
Questions/Answers
Does anyone have a question?
Let’s Stay In Touch
Contact me:
joseph.beale92@gmail.com
Connect with me on LinkedIn:
www.linkedin.com/in/JosephBealeQA
Follow me on Twitter: @JosephBealeQA

Weitere ähnliche Inhalte

Was ist angesagt?

Front Ends for Back End Developers - Spring I/O 2017
Front Ends for Back End Developers - Spring I/O 2017Front Ends for Back End Developers - Spring I/O 2017
Front Ends for Back End Developers - Spring I/O 2017Matt Raible
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial IntroPamela Fox
 
Wookie Meetup
Wookie MeetupWookie Meetup
Wookie Meetupscottw
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introductionTomi Juhola
 
Advanced java script essentials v1
Advanced java script essentials v1Advanced java script essentials v1
Advanced java script essentials v1ASHUTOSHPATKAR1
 
Learning from the Best jQuery Plugins
Learning from the Best jQuery PluginsLearning from the Best jQuery Plugins
Learning from the Best jQuery PluginsMarc Grabanski
 
Local SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLocal SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLaurence Svekis ✔
 
The Art of AngularJS in 2015
The Art of AngularJS in 2015The Art of AngularJS in 2015
The Art of AngularJS in 2015Matt Raible
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web PerformanceAdam Lu
 
Testing web APIs
Testing web APIsTesting web APIs
Testing web APIsFDConf
 
Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Matt Raible
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015Chang W. Doh
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppKaty Slemon
 
Introduction to App Engine Development
Introduction to App Engine DevelopmentIntroduction to App Engine Development
Introduction to App Engine DevelopmentRon Reiter
 

Was ist angesagt? (19)

Front Ends for Back End Developers - Spring I/O 2017
Front Ends for Back End Developers - Spring I/O 2017Front Ends for Back End Developers - Spring I/O 2017
Front Ends for Back End Developers - Spring I/O 2017
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
Wookie Meetup
Wookie MeetupWookie Meetup
Wookie Meetup
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
Advanced java script essentials v1
Advanced java script essentials v1Advanced java script essentials v1
Advanced java script essentials v1
 
Learning from the Best jQuery Plugins
Learning from the Best jQuery PluginsLearning from the Best jQuery Plugins
Learning from the Best jQuery Plugins
 
Local SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLocal SQLite Database with Node for beginners
Local SQLite Database with Node for beginners
 
Django
DjangoDjango
Django
 
The Art of AngularJS in 2015
The Art of AngularJS in 2015The Art of AngularJS in 2015
The Art of AngularJS in 2015
 
Grails and Dojo
Grails and DojoGrails and Dojo
Grails and Dojo
 
Enhance Web Performance
Enhance Web PerformanceEnhance Web Performance
Enhance Web Performance
 
Testing web APIs
Testing web APIsTesting web APIs
Testing web APIs
 
BDD with cucumber
BDD with cucumberBDD with cucumber
BDD with cucumber
 
Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021
 
Web Components
Web ComponentsWeb Components
Web Components
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular App
 
Introduction to App Engine Development
Introduction to App Engine DevelopmentIntroduction to App Engine Development
Introduction to App Engine Development
 

Andere mochten auch

Testing and checking by Newton Olivieri
Testing and checking by Newton OlivieriTesting and checking by Newton Olivieri
Testing and checking by Newton OlivieriQA or the Highway
 
Create testing commandos for creative problem solving!!! by Pradeepa Narayana...
Create testing commandos for creative problem solving!!! by Pradeepa Narayana...Create testing commandos for creative problem solving!!! by Pradeepa Narayana...
Create testing commandos for creative problem solving!!! by Pradeepa Narayana...QA or the Highway
 
Security Testing by Ken De Souza
Security Testing by Ken De SouzaSecurity Testing by Ken De Souza
Security Testing by Ken De SouzaQA or the Highway
 
Bringing the hacker mindset into requirements and testing by Eapen Thomas and...
Bringing the hacker mindset into requirements and testing by Eapen Thomas and...Bringing the hacker mindset into requirements and testing by Eapen Thomas and...
Bringing the hacker mindset into requirements and testing by Eapen Thomas and...QA or the Highway
 
Digital transformation continues to drive IT strategy, How is QA and testing ...
Digital transformation continues to drive IT strategy, How is QA and testing ...Digital transformation continues to drive IT strategy, How is QA and testing ...
Digital transformation continues to drive IT strategy, How is QA and testing ...QA or the Highway
 

Andere mochten auch (6)

Defect Triage by Matt Eakin
Defect Triage by Matt EakinDefect Triage by Matt Eakin
Defect Triage by Matt Eakin
 
Testing and checking by Newton Olivieri
Testing and checking by Newton OlivieriTesting and checking by Newton Olivieri
Testing and checking by Newton Olivieri
 
Create testing commandos for creative problem solving!!! by Pradeepa Narayana...
Create testing commandos for creative problem solving!!! by Pradeepa Narayana...Create testing commandos for creative problem solving!!! by Pradeepa Narayana...
Create testing commandos for creative problem solving!!! by Pradeepa Narayana...
 
Security Testing by Ken De Souza
Security Testing by Ken De SouzaSecurity Testing by Ken De Souza
Security Testing by Ken De Souza
 
Bringing the hacker mindset into requirements and testing by Eapen Thomas and...
Bringing the hacker mindset into requirements and testing by Eapen Thomas and...Bringing the hacker mindset into requirements and testing by Eapen Thomas and...
Bringing the hacker mindset into requirements and testing by Eapen Thomas and...
 
Digital transformation continues to drive IT strategy, How is QA and testing ...
Digital transformation continues to drive IT strategy, How is QA and testing ...Digital transformation continues to drive IT strategy, How is QA and testing ...
Digital transformation continues to drive IT strategy, How is QA and testing ...
 

Ähnlich wie Page object from the ground up by Joe Beale

Cucumber From the Ground Up - Joseph Beale
Cucumber From the Ground Up - Joseph BealeCucumber From the Ground Up - Joseph Beale
Cucumber From the Ground Up - Joseph BealeQA or the Highway
 
Test Automation using Ruby
Test Automation using Ruby Test Automation using Ruby
Test Automation using Ruby Sla Va
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentEvan Mullins
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]GDSC UofT Mississauga
 
Aucd ppt
Aucd pptAucd ppt
Aucd ppticidemo
 
Using the WordPress REST API and Gatsby.js
Using the WordPress REST API and Gatsby.jsUsing the WordPress REST API and Gatsby.js
Using the WordPress REST API and Gatsby.jsIndigo Tree Digital
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code維佋 唐
 
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliGetting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliRebecca Eloise Hogg
 
Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidgetHiron Das
 
Cocoon gem example
Cocoon gem exampleCocoon gem example
Cocoon gem exampleKaty Slemon
 
Progressive EPiServer Development
Progressive EPiServer DevelopmentProgressive EPiServer Development
Progressive EPiServer Developmentjoelabrahamsson
 
Web driver selenium simplified
Web driver selenium simplifiedWeb driver selenium simplified
Web driver selenium simplifiedVikas Singh
 
La build your own website september 5
La build your own website september 5La build your own website september 5
La build your own website september 5Thinkful
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Againjonknapp
 
Volley lab btc_bbit
Volley lab btc_bbitVolley lab btc_bbit
Volley lab btc_bbitCarWash1
 
Introduction To Ruby Watir (Web Application Testing In Ruby)
Introduction To Ruby Watir (Web Application Testing In Ruby)Introduction To Ruby Watir (Web Application Testing In Ruby)
Introduction To Ruby Watir (Web Application Testing In Ruby)Mindfire Solutions
 

Ähnlich wie Page object from the ground up by Joe Beale (20)

Cucumber From the Ground Up - Joseph Beale
Cucumber From the Ground Up - Joseph BealeCucumber From the Ground Up - Joseph Beale
Cucumber From the Ground Up - Joseph Beale
 
Test Automation using Ruby
Test Automation using Ruby Test Automation using Ruby
Test Automation using Ruby
 
Javascript projects Course
Javascript projects CourseJavascript projects Course
Javascript projects Course
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Aucd ppt
Aucd pptAucd ppt
Aucd ppt
 
Using the WordPress REST API and Gatsby.js
Using the WordPress REST API and Gatsby.jsUsing the WordPress REST API and Gatsby.js
Using the WordPress REST API and Gatsby.js
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
Fccwc326
Fccwc326Fccwc326
Fccwc326
 
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliGetting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
 
Android how to hellowidget
Android how to hellowidgetAndroid how to hellowidget
Android how to hellowidget
 
Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidget
 
Cocoon gem example
Cocoon gem exampleCocoon gem example
Cocoon gem example
 
Progressive EPiServer Development
Progressive EPiServer DevelopmentProgressive EPiServer Development
Progressive EPiServer Development
 
Web driver selenium simplified
Web driver selenium simplifiedWeb driver selenium simplified
Web driver selenium simplified
 
La build your own website september 5
La build your own website september 5La build your own website september 5
La build your own website september 5
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Again
 
Volley lab btc_bbit
Volley lab btc_bbitVolley lab btc_bbit
Volley lab btc_bbit
 
Introduction To Ruby Watir (Web Application Testing In Ruby)
Introduction To Ruby Watir (Web Application Testing In Ruby)Introduction To Ruby Watir (Web Application Testing In Ruby)
Introduction To Ruby Watir (Web Application Testing In Ruby)
 
Web Scrapping Using Python
Web Scrapping Using PythonWeb Scrapping Using Python
Web Scrapping Using Python
 

Mehr von QA or the Highway

KrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdfKrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdfQA or the Highway
 
Ravi Lakkavalli - World Quality Report.pptx
Ravi Lakkavalli - World Quality Report.pptxRavi Lakkavalli - World Quality Report.pptx
Ravi Lakkavalli - World Quality Report.pptxQA or the Highway
 
Caleb Crandall - Testing Between the Buckets.pptx
Caleb Crandall - Testing Between the Buckets.pptxCaleb Crandall - Testing Between the Buckets.pptx
Caleb Crandall - Testing Between the Buckets.pptxQA or the Highway
 
Thomas Haver - Mobile Testing.pdf
Thomas Haver - Mobile Testing.pdfThomas Haver - Mobile Testing.pdf
Thomas Haver - Mobile Testing.pdfQA or the Highway
 
Thomas Haver - Example Mapping.pdf
Thomas Haver - Example Mapping.pdfThomas Haver - Example Mapping.pdf
Thomas Haver - Example Mapping.pdfQA or the Highway
 
Joe Colantonio - Actionable Automation Awesomeness in Testing Farm.pdf
Joe Colantonio - Actionable Automation Awesomeness in Testing Farm.pdfJoe Colantonio - Actionable Automation Awesomeness in Testing Farm.pdf
Joe Colantonio - Actionable Automation Awesomeness in Testing Farm.pdfQA or the Highway
 
Sarah Geisinger - Continious Testing Metrics That Matter.pdf
Sarah Geisinger - Continious Testing Metrics That Matter.pdfSarah Geisinger - Continious Testing Metrics That Matter.pdf
Sarah Geisinger - Continious Testing Metrics That Matter.pdfQA or the Highway
 
Jeff Sing - Quarterly Service Delivery Reviews.pdf
Jeff Sing - Quarterly Service Delivery Reviews.pdfJeff Sing - Quarterly Service Delivery Reviews.pdf
Jeff Sing - Quarterly Service Delivery Reviews.pdfQA or the Highway
 
Leandro Melendez - Chihuahua Load Tests.pdf
Leandro Melendez - Chihuahua Load Tests.pdfLeandro Melendez - Chihuahua Load Tests.pdf
Leandro Melendez - Chihuahua Load Tests.pdfQA or the Highway
 
Rick Clymer - Incident Management.pdf
Rick Clymer - Incident Management.pdfRick Clymer - Incident Management.pdf
Rick Clymer - Incident Management.pdfQA or the Highway
 
Robert Fornal - ChatGPT as a Testing Tool.pptx
Robert Fornal - ChatGPT as a Testing Tool.pptxRobert Fornal - ChatGPT as a Testing Tool.pptx
Robert Fornal - ChatGPT as a Testing Tool.pptxQA or the Highway
 
Federico Toledo - Extra-functional testing.pdf
Federico Toledo - Extra-functional testing.pdfFederico Toledo - Extra-functional testing.pdf
Federico Toledo - Extra-functional testing.pdfQA or the Highway
 
Andrew Knight - Managing the Test Data Nightmare.pptx
Andrew Knight - Managing the Test Data Nightmare.pptxAndrew Knight - Managing the Test Data Nightmare.pptx
Andrew Knight - Managing the Test Data Nightmare.pptxQA or the Highway
 
Melissa Tondi - Automation We_re Doing it Wrong.pdf
Melissa Tondi - Automation We_re Doing it Wrong.pdfMelissa Tondi - Automation We_re Doing it Wrong.pdf
Melissa Tondi - Automation We_re Doing it Wrong.pdfQA or the Highway
 
Jeff Van Fleet and John Townsend - Transition from Testing to Leadership.pdf
Jeff Van Fleet and John Townsend - Transition from Testing to Leadership.pdfJeff Van Fleet and John Townsend - Transition from Testing to Leadership.pdf
Jeff Van Fleet and John Townsend - Transition from Testing to Leadership.pdfQA or the Highway
 
DesiradhaRam Gadde - Testers _ Testing in ChatGPT-AI world.pptx
DesiradhaRam Gadde - Testers _ Testing in ChatGPT-AI world.pptxDesiradhaRam Gadde - Testers _ Testing in ChatGPT-AI world.pptx
DesiradhaRam Gadde - Testers _ Testing in ChatGPT-AI world.pptxQA or the Highway
 
Damian Synadinos - Word Smatter.pdf
Damian Synadinos - Word Smatter.pdfDamian Synadinos - Word Smatter.pdf
Damian Synadinos - Word Smatter.pdfQA or the Highway
 
Lee Barnes - What Successful Test Automation is.pdf
Lee Barnes - What Successful Test Automation is.pdfLee Barnes - What Successful Test Automation is.pdf
Lee Barnes - What Successful Test Automation is.pdfQA or the Highway
 
Jordan Powell - API Testing with Cypress.pptx
Jordan Powell - API Testing with Cypress.pptxJordan Powell - API Testing with Cypress.pptx
Jordan Powell - API Testing with Cypress.pptxQA or the Highway
 
Carlos Kidman - Exploring AI Applications in Testing.pptx
Carlos Kidman - Exploring AI Applications in Testing.pptxCarlos Kidman - Exploring AI Applications in Testing.pptx
Carlos Kidman - Exploring AI Applications in Testing.pptxQA or the Highway
 

Mehr von QA or the Highway (20)

KrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdfKrishnaToolComparisionPPT.pdf
KrishnaToolComparisionPPT.pdf
 
Ravi Lakkavalli - World Quality Report.pptx
Ravi Lakkavalli - World Quality Report.pptxRavi Lakkavalli - World Quality Report.pptx
Ravi Lakkavalli - World Quality Report.pptx
 
Caleb Crandall - Testing Between the Buckets.pptx
Caleb Crandall - Testing Between the Buckets.pptxCaleb Crandall - Testing Between the Buckets.pptx
Caleb Crandall - Testing Between the Buckets.pptx
 
Thomas Haver - Mobile Testing.pdf
Thomas Haver - Mobile Testing.pdfThomas Haver - Mobile Testing.pdf
Thomas Haver - Mobile Testing.pdf
 
Thomas Haver - Example Mapping.pdf
Thomas Haver - Example Mapping.pdfThomas Haver - Example Mapping.pdf
Thomas Haver - Example Mapping.pdf
 
Joe Colantonio - Actionable Automation Awesomeness in Testing Farm.pdf
Joe Colantonio - Actionable Automation Awesomeness in Testing Farm.pdfJoe Colantonio - Actionable Automation Awesomeness in Testing Farm.pdf
Joe Colantonio - Actionable Automation Awesomeness in Testing Farm.pdf
 
Sarah Geisinger - Continious Testing Metrics That Matter.pdf
Sarah Geisinger - Continious Testing Metrics That Matter.pdfSarah Geisinger - Continious Testing Metrics That Matter.pdf
Sarah Geisinger - Continious Testing Metrics That Matter.pdf
 
Jeff Sing - Quarterly Service Delivery Reviews.pdf
Jeff Sing - Quarterly Service Delivery Reviews.pdfJeff Sing - Quarterly Service Delivery Reviews.pdf
Jeff Sing - Quarterly Service Delivery Reviews.pdf
 
Leandro Melendez - Chihuahua Load Tests.pdf
Leandro Melendez - Chihuahua Load Tests.pdfLeandro Melendez - Chihuahua Load Tests.pdf
Leandro Melendez - Chihuahua Load Tests.pdf
 
Rick Clymer - Incident Management.pdf
Rick Clymer - Incident Management.pdfRick Clymer - Incident Management.pdf
Rick Clymer - Incident Management.pdf
 
Robert Fornal - ChatGPT as a Testing Tool.pptx
Robert Fornal - ChatGPT as a Testing Tool.pptxRobert Fornal - ChatGPT as a Testing Tool.pptx
Robert Fornal - ChatGPT as a Testing Tool.pptx
 
Federico Toledo - Extra-functional testing.pdf
Federico Toledo - Extra-functional testing.pdfFederico Toledo - Extra-functional testing.pdf
Federico Toledo - Extra-functional testing.pdf
 
Andrew Knight - Managing the Test Data Nightmare.pptx
Andrew Knight - Managing the Test Data Nightmare.pptxAndrew Knight - Managing the Test Data Nightmare.pptx
Andrew Knight - Managing the Test Data Nightmare.pptx
 
Melissa Tondi - Automation We_re Doing it Wrong.pdf
Melissa Tondi - Automation We_re Doing it Wrong.pdfMelissa Tondi - Automation We_re Doing it Wrong.pdf
Melissa Tondi - Automation We_re Doing it Wrong.pdf
 
Jeff Van Fleet and John Townsend - Transition from Testing to Leadership.pdf
Jeff Van Fleet and John Townsend - Transition from Testing to Leadership.pdfJeff Van Fleet and John Townsend - Transition from Testing to Leadership.pdf
Jeff Van Fleet and John Townsend - Transition from Testing to Leadership.pdf
 
DesiradhaRam Gadde - Testers _ Testing in ChatGPT-AI world.pptx
DesiradhaRam Gadde - Testers _ Testing in ChatGPT-AI world.pptxDesiradhaRam Gadde - Testers _ Testing in ChatGPT-AI world.pptx
DesiradhaRam Gadde - Testers _ Testing in ChatGPT-AI world.pptx
 
Damian Synadinos - Word Smatter.pdf
Damian Synadinos - Word Smatter.pdfDamian Synadinos - Word Smatter.pdf
Damian Synadinos - Word Smatter.pdf
 
Lee Barnes - What Successful Test Automation is.pdf
Lee Barnes - What Successful Test Automation is.pdfLee Barnes - What Successful Test Automation is.pdf
Lee Barnes - What Successful Test Automation is.pdf
 
Jordan Powell - API Testing with Cypress.pptx
Jordan Powell - API Testing with Cypress.pptxJordan Powell - API Testing with Cypress.pptx
Jordan Powell - API Testing with Cypress.pptx
 
Carlos Kidman - Exploring AI Applications in Testing.pptx
Carlos Kidman - Exploring AI Applications in Testing.pptxCarlos Kidman - Exploring AI Applications in Testing.pptx
Carlos Kidman - Exploring AI Applications in Testing.pptx
 

Kürzlich hochgeladen

Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrHenryBriggs2
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...SUHANI PANDEY
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋nirzagarg
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLimonikaupta
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge GraphsEleniIlkou
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfJOHNBEBONYAP1
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)Delhi Call girls
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...roncy bisnoi
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"growthgrids
 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...SUHANI PANDEY
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Delhi Call girls
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...SUHANI PANDEY
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...SUHANI PANDEY
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceDelhi Call girls
 

Kürzlich hochgeladen (20)

Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 

Page object from the ground up by Joe Beale

  • 1. Page Object From the Ground Up Joseph Beale 02/07/2017
  • 2. Agenda 1. Prepare the Environment 2.Build Automated Test using Watir 3.Convert to Page Object 4.Final Test Run 5.Q&A and Fun Time
  • 3. But first... Could I have a volunteer from the audience?
  • 4. Environment Create a folder called “test_project” under c:rubyprograms
  • 5. Environment Inside of test_project, create a folder called “features”. Then inside of that, create three more called “step_definitions”, “support”, and “pages”.
  • 6. Environment Open up the features -> support folder and create a new text file called “env.rb”.
  • 7. Environment This demonstration will require you to have Ruby installed on your system. For this, go to https://rubyinstaller.org/ and download the necessary installer. Then follow the directions there. After installing Ruby, grab the Cucumber gem by typing “gem install cucumber” at a command prompt.
  • 8. Environment We will need two more gems for this demonstration: • rspec • page-object Q: What is a Ruby gem? A: A pre-built code module that performs some useful function in Ruby, available for free from https://rubygems.org
  • 9. Environment Open up env.rb using Notepad++ (free download) and add the following statements: Require statements tell Ruby that you are going to use some extra code modules.
  • 10. Build Create a feature file and a test scenario: Cucumber scenarios are written in ordinary business language using Gherkin keywords (“Feature:”, “Scenario:”, “Given”, “When”, “Then”, “And”, “But”).
  • 11. Build Optional: Create a batch file to execute your test.
  • 12. Build These commands tell the operating system to: 1.Open up a new command prompt in the current directory (c:rubyprogramstest_project). 2.Execute the “cucumber” command 3.Create a new report called “report.html” and format it as an html document. 4.Open up the report.
  • 13. Build You can go ahead and run the test with no other effort. It will not do much, but Cucumber will give you a head start:
  • 14. Build Create a file called “my_steps.rb” in the step_definitions folder and paste the helper code snippets there:
  • 15. Build First step: Given I am on the Bing home page To satisfy this step, we need to open a browser and navigate to the Bing home page. How do we do this in Ruby?
  • 16. Build using Watir Source: https://watir.github.io/
  • 17. Build using Watir Right on the front page is the code we need to create a browser object (along with lots of other helpful code): We will use these exact lines of code but modify them for our purposes.
  • 18. Build using Watir We will create “$browser” using the code they gave us, but we will put it in the env.rb file so that it is created before any of the steps are run:
  • 19. Build using Watir Q: Why did you put a ‘$’ in front of your object name? A: To indicate that it is a global variable. We want the browser object to be accessible to all steps, so we make it global.
  • 20. Build using Watir In the first step definition, we will put the next line of code, but modified to reflect our global browser object and the URL for Bing.com: Now when we run our test we will get...
  • 21. Build using Watir ...the Bing home page!
  • 22. Build using Watir Note that our report now shows one step is green, meaning that it has passed:
  • 23. Build using Watir A quick word about method calls: the format for calling a method in Ruby is (object name) + dot (‘.’) + (method name). So in the method call below, the object name is ‘$browser’ and the method name is ‘goto’.
  • 24. Build using Watir The ‘goto’ method is just one of the pre- defined methods inside of the Watir::Browser class. The method takes one argument: a URL (because it needs to know where to “go to”). Arguments can be passed either inside of parentheses or alongside a method call. So in the previous example we could have said: $browser.goto(‘bing.com’)
  • 25. Build using Watir Second step: When I search the phrase "Call me Ishmael" To automate this step, we need to interact with two elements on the page: 1. The search text field 2. The search button (indicated by the magnifying glass icon).
  • 26. Build using Watir Watir has several methods in the Browser class to interact with the elements that are common to most web pages. The two we need are listed in the example given on their home page (right under the ‘goto’):
  • 27. Build using Watir To interact with the two search elements, we will use the ‘text_field’ and ‘button’ methods. These two methods each take one argument: a locator as indicated by the syntax (locator: ‘unique_identifier’). For example: $browser.text_field(id: ‘my_id’).set ‘my text’ $browser.button(id: ‘my_button’).click
  • 28. Build using Watir The locators are part of the page’s Document Object Model or DOM, which is a model of the page’s html code. But you don’t need to understand the underlying code; all you need to know is how to inspect your desired elements.
  • 29. Build using Watir If you are using Chrome browser, you can activate DevTools in three ways: Source: https://developers.google.com/web/tools/chrome-devtools/
  • 30. Build using Watir Inspecting the search box yields:
  • 31. Build using Watir The most common locator to use is ‘id’, so we will copy the value for the id locator (“sb_form_q”) and use it in our code for the text_field method.
  • 32. Build using Watir Once nice feature of Ruby method calls is the ability to “chain” methods one right after another. Ruby will execute them in the order given, from left to right. That is what you see in the text_field example: The ‘set’ method is executed right after the text_field method.
  • 33. Build using Watir You can use the ‘set’ method anytime you have defined a text field element using the ‘text_field’ method. It takes one argument: the word or phrase that you wish to place in the field. So, substituting a helpful variable name like “search_phrase” for “arg1” in the code snippet, the code for our second step looks like this:
  • 34. Build using Watir Q: Where does the value for “search_phrase” come from? A: It is passed into the code from the Gherkin step using a capture group. This cryptic bit of code "([^"]*)" grabs whatever is between the double-quotes and throws it into my given variable.
  • 35. Build using Watir Since the variable search_phrase is a string, we can use it as an argument for the set method. And so then we are able to use that same Ruby code block no matter what phrase is used in the Gherkin. Step → Step definition →
  • 36. Build using Watir Now running the test yields:
  • 37. For the button element, we’ll do it exactly like we did the text field except that instead of using the set method we will need to find a method that will click the button. The method name in this case is - surprise! - click. From the Watir site: browser.button(type: 'submit').click
  • 38. Build using Watir For most buttons, the locator they are using (type: ‘submit’) will work but it’s not specific enough so we’ll use the id to locate the field. Adding that and the dollar sign for the global variable, our step definition looks like this:
  • 39. Build using Watir Running again we get:
  • 40. Build using Watir And in the report two steps are now green:
  • 41. Build using Watir Third step: Then I will see results that contain “Moby Dick” Somehow we need to get our code to examine the result page and check to see if our phrase “Moby Dick” is found anywhere. This is where the RSpec gem comes in handy.
  • 42. Build using Watir There are many different ways to compare fields using RSpec, but the one we will use is a combination of “should” and “include”. To locate the results area, we found that we can use the ‘div’ method and an id of ‘b_content’.
  • 43. Build using Watir Running again causes all steps to pass:
  • 44. Why Page Object The Problem: If you have multiple tests or even multiple steps that use the same page elements, it’s tedious to keep having to locate them by id again and again. The Solution: Store all of the attributes for any given page in one place, assign them labels, and then in your steps simply refer to the pages and the labels.
  • 45. Convert to Page Object The Page Object gem requires some additional lines of code in the env.rb file: Hint: code it and forget it.
  • 46. Convert to Page Object For each page where we need to interact with fields or other attributes, we will need to create a class (blueprint for an object):
  • 47. Convert to Page Object When we create a class to represent a page, we are creating a situation where the attributes of the page are already defined and they are just waiting for the page object to be instantiated by creating a new instance of the class. Once that is done, the user has access to all of the attribute methods.
  • 48. Convert to Page Object Digging into the code for the two page classes:
  • 49. Convert to Page Object Q: Why use ‘include’? A: This will pull all of the standard Page Object methods into your class. http://www.rubydoc.info/github/cheezy/page-object/PageObject/Accessors
  • 50. Convert to Page Object For example:
  • 51. Convert to Page Object Here is what our steps will look like:
  • 52. Convert to Page Object Special Page Object Methods visit - grabs the URL passed to the ‘page_url’ method and executes a ‘goto’ method on it. on_page or on - instantiates the named page and allows you to access its attributes and their methods.
  • 53. Final Test Run Running again, we see the steps are still green:
  • 55. Let’s Stay In Touch Contact me: joseph.beale92@gmail.com Connect with me on LinkedIn: www.linkedin.com/in/JosephBealeQA Follow me on Twitter: @JosephBealeQA