Skip to content

Instantly share code, notes, and snippets.

@alisterscott
Forked from natritmeyer/block_suggestion.rb
Created May 31, 2012 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alisterscott/2847235 to your computer and use it in GitHub Desktop.
Save alisterscott/2847235 to your computer and use it in GitHub Desktop.
Page Object Management blog post material
visit LoginPage do |page|
page.login_with('foo', 'badpass')
page.text.should include "Login error"
page.text.should include "Secure your account"
end
class App
def home
HomePage.new #returns an instance of the HomePage class
end
def login_page
LoginPage.new
end
def account_page
AccountPage.new
end
def account_history_page
AccountHistoryPage.new
end
end
When /^I log in as the administrator$/ do
@app.home.expand_user_section
@app.home.sign_in.click
@app.login.username.set "admin"
@app.login.password.set "p4ssword"
@app.login.login_button.click
end
When /^I visit the (home|login|account|account history) page$/ do |page_name|
visit App.new.send page_name
end
@login_page = LoginPage.new # <= dirt
@login_page.login_with "bob", "p4ssword"
@account_page = AccountPage.new # <= more dirt
@account_page.username.text.should == "bob"
@account_page.view_account_history.click
@account_history_page = AccountHistoryPage.new # <= yet more dirt
@account_history_page.purchased_items.size.should == 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment