A
A
Serif
Sans
White
Sepia
Night
Star (
-
)
Watch (
-
)
BDD with PageObject
About the author
Questions and Issues
Edit and Contribute
Introduction
1.
Environment Setup
1.1.
Install Ruby
1.2.
Install Cucumber and WebDriver
1.3.
Install Rspec
1.4.
Summary
2.
A simple Ruby script with Selenium-WebDriver
2.1.
Import required libs
2.2.
Initial Browser
2.3.
Open Google in browser
2.4.
Search by keyword
2.5.
Print the browser's title twice
2.6.
Close browser and exit "irb"
2.7.
Run the script we just input in "irb"
2.8.
Summary
3.
Start with Cucumber
3.1.
Build calculator functions to test with in Ruby
3.2.
Create Cucumber feature file to test calculator
3.3.
Add feature to test addition in calculator
3.4.
Add feature to test division in calculator
3.5.
Add step definitions to support feature files
3.6.
Run Cucumber features
3.7.
Summary
4.
Migrate the Selenium-WebDriver sample to Cucumber feature
4.1.
Add feature file of Selenium-WebDriver sample
4.2.
Add step definitions to support sample feature
4.3.
Separate the content in Selenium-WebDriver sample.rb into different sections
4.4.
Extract Google URL as a parameter
4.5.
Extract search keyword as a parameter
4.6.
Run cucumber to see the result of Selenium-WebDriver sample test
4.7.
Add assertion to both feature and step definition
4.8.
Run cucumber test with assertion
4.9.
Extract the setup and tire down steps into features/support/env.rb
4.10.
Run Cucumber test with env.rb
4.11.
Summary
5.
Use BDD in the real world
5.1.
Add feature for buying book
5.2.
Add step definitions for buying book
5.3.
Extract the step of opening site into a method
5.4.
Extract the step of searching by keyword into a method
5.5.
Extract the step of opening the first book into a method
5.6.
Extract the step of adding first book to shopping cart into methods
5.7.
Extract the step of verifying item in shopping cart into methods
5.8.
Extract method find_element into a generic method findElementBy(type,value)
5.9.
Combine the methods findElementBy(type,value) and element.click into one single method clickElementBy(type,value)
5.10.
Run the buying book feature to see the result
5.11.
Add feature for removing book from shopping cart
5.12.
Add step definitions for removing book
5.13.
Add time out settings to env.rb
5.14.
Run the removing book feature to see the result
5.15.
Add a data driven scenario of adding book feature
5.16.
Add tags to different scenarios to run them separately
5.17.
Run the buying book feature with tags
5.18.
Add scenario of adding book to shopping cart from wish list
5.19.
Add step definitions for adding book to shopping cart from wish list
5.20.
Extract findElementBy and ClickElementBy in steps into meaningful methods
5.21.
Add taking screenshot to the assertion step
5.22.
Run the buying book from wish list feature
5.23.
Summary
6.
How to adopt Page Object Pattern in BDD
6.1.
Create folder structure for pages
6.2.
Create base page to contains all methods
6.3.
Create child page - home page
6.4.
Create child page - item details page
6.5.
Create child page - login page
6.6.
Create child page - search result page
6.7.
Create child page - shopping cart page
6.8.
Create child page - wish list page
6.9.
Update base page
6.10.
Update env.rb
6.11.
Update buy_book.rb
6.12.
Update remove_book.rb
6.13.
Generate ‘pretty’ report
6.14.
Summary
Generated using GitBook
Run cucumber test with assertion
Let's run the sample test with assertion under "Cucumber" folder.
cucumber features/sample.feature