Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am smills24 on github.
  • I am smills24 (https://keybase.io/smills24) on keybase.
  • I have a public key whose fingerprint is AE21 49E6 B4FC B0E8 59C7 2494 B423 8A10 1B70 2A77

To claim this, I am signing this object:

@smills24
smills24 / pageobjects.md
Last active Oct 10, 2015
Reasons You Should Use the Page Object Pattern in Your Automated Tests
View pageobjects.md

Reasons You Should Use the Page Object Pattern in Your Automated Tests

Are you plagued by a brittle automated test suite?

Every time you change a few lines of application code, do you find yourself having to edit dozens of lines of test code to get them passing again?

If this sounds familiar, it's probably an indication your automated test code suffers from disorganization or unnecessary duplication. Test code is often procedural in nature, but applying some OOP and "clean code" principles and patterns can go a long way in extending the life and maintainability of a test suite.

One of these is the object pattern, defined on Selenium's wiki. You create classes which represent an HTML page under test (or a part of the page, such as a navigation bar or a table). A test then instantiates a page object and interacts with it through its public methods. These methods expose the high-level services offered by a page using an intention-revealing DSL. At the s

@smills24
smills24 / test_spec.rb
Created Feb 1, 2012
Failing Capybara/Selenium test
View test_spec.rb
require 'spec_helper'
describe "Failing test" do, :type => :request do
before(:all) do
visit "http://www.google.com"
end
it "passes the first test" do
page.should have_css("input")