Skip to content

Instantly share code, notes, and snippets.

@bfaloona
Created November 22, 2010 15:26
Show Gist options
  • Save bfaloona/710107 to your computer and use it in GitHub Desktop.
Save bfaloona/710107 to your computer and use it in GitHub Desktop.
Access to WatirCraft Methods from WatirCraft page classes
# lib/methods/versions.rb
module MyProject
module Methods
def app_version
browser.url.match(/\/myproject\/([0-9]{2})\//)[1].to_i
end
end
end
# lib/pages/versioned_page.rb
module MyProject
class VersionedPage < Taza::Page
# in order to make app_version() available,
# this explicit include is required on every page class (with :: prepended)
include ::MyProject::Methods
field(:versioned_textbox) do
if app_version > 3
browser.text_field(:id, 'text3')
else
browser.text_field(:id, 'text5')
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment