Created
January 7, 2013 20:04
-
-
Save adamgoucher/4477924 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # this is in chemistry kit | |
| module ChemistryKit | |
| module PageObject | |
| def initialize(driver) | |
| @driver = browser | |
| super | |
| end | |
| end | |
| end | |
| # this is the userland facade | |
| module YourProject | |
| module PageObject | |
| include ChemistryKit::PageObject | |
| def initialize(driver) | |
| super | |
| end | |
| end | |
| end | |
| # this is the actual page object | |
| require 'lib/pages/otherpage' | |
| class MyLoginPageObject | |
| include YourProject::PageObject | |
| attr_reader :driver | |
| text_field(:username, :id => 'username') | |
| text_field(:password, :id => 'password') | |
| button(:login, :id => 'login') | |
| def initialize(driver) | |
| super | |
| end | |
| def open | |
| driver.open(CHEMISTRY_CONFIG['chemistrykit']['baseurl'] + '/foo') | |
| end | |
| def wait_until_loaded | |
| wait = Selenium::WebDriver::Wait.new(:timeout => CHEMISTRY_CONFIG['chemistrykit']['timeout']) | |
| wait.until { @driver.find_element(:id => "cheese").displayed? } | |
| end | |
| def validate | |
| end | |
| def login_with(username, password) | |
| self.username = username | |
| self.password = password | |
| login | |
| OtherPage(@driver).wait_until_loaded | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment