forked from scudco/taza
-
Notifications
You must be signed in to change notification settings - Fork 19
Elements
angupta edited this page Sep 13, 2010
·
5 revisions
Elements exist on Pages
An example of the search text field on the Google home page in WATIR syntax:
module Google
class HomePage < Taza::Page
element(:search_field) { browser.text_field(:name, 'q') }
end
end
This element can then be accessed like:
Google.new do |google|
google.home_page.search_field.set 'ruby'
#or
google.home_page do |hp|
hp.search_field.set 'ruby'
end
end
Since elements take blocks they can be more powerful than simply returning a value:
module Google
class SearchResultsPage < Taza::Page
element(:page_link) {|page_number| browser.link(:text,page_number.to_s) }
end
end
This element can then be accessed like:
Google.new do |google|
google.search_results_page.page_link(3).click
#or
google.search_results_page do |srp|
srp.page_link(3).click
end
end
Elements can also be divided into Page Modules for better readability.