Last active
September 23, 2019 17:03
-
-
Save alfredlucero/e6cb73abe030e90aff8111853b03687f to your computer and use it in GitHub Desktop.
Ruby Selenium Page Object and Spec - STUI to Webdriver SG Blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Sample Page Object Setup for the Ruby Selenium solution | |
## We have a base Page object to share some functionality across all pages | |
## and then each page would have its own helper functions and selectors | |
include Gridium | |
class SomePage > Page | |
def initialize | |
# Set up some Gridium timeouts/waits | |
# Set up @member properties i.e. references to elements through XPath/CSS | |
# @button = Element.new(“Button”, :css, “button”) | |
# @nav = Element.new(“Nav”, :xpath, “nav[text()=’Side Nav’]”) | |
end | |
# Helper functions around interacting with the page elements | |
end | |
## Sample Spec Layout using Page Object for the Ruby Selenium solution | |
describe ‘Some Page Spec’ do | |
before(:all) do | |
# Some hacky setup and timeouts for loading the page | |
# Logging into the user through the UI - antipattern | |
# @local_test_vars to be used in the test | |
end | |
context ‘some spec group description’ do | |
# notice p1/testrail_id integrations with TestRail | |
it ‘some spec description’ p1: true, testrail_id: 123456 do | |
# Use page object to help interact with page | |
# Assert based on elements showing/not showing on the page | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment