Created
February 10, 2015 19:17
-
-
Save tourdedave/ced16a4a2c7f423993b7 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
# pages/top-nav-widget.rb | |
module PageObject | |
module TopNavWidget | |
FORK_LINK = { css: 'img' } | |
end | |
end | |
# pages/login-page.rb | |
module PageObject | |
class LoginPage | |
include TopNavWidget | |
def initialize(driver) | |
@driver = driver | |
@driver.get 'http://the-internet.herokuapp.com/login' | |
end | |
def nav_text | |
@driver.find_element(FORK_LINK).attribute('alt') | |
end | |
end | |
end | |
# example.rb | |
require 'selenium-webdriver' | |
driver = Selenium::WebDriver.for :firefox | |
driver.get('http://the-internet.herokuapp.com') | |
link = driver.find_element(PageObject::TopNavWidget::FORK_LINK) | |
puts link.attribute('alt') | |
login = PageObject::LoginPage.new(driver) | |
puts login.nav_text | |
driver.quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment