This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Filters
Filters are used to define states of Pages
As an example the Google home page displays a different user control panel in the upper right corner depending on whether or not the user is signed in.
module Google
class HomePage < Taza::Page
filter :logged_in?, :sign_out, :my_account
element(:user_panel) { browser.div(:id,'guser') }
element(:sign_in) { browser.link(:text,'Sign in') }
element(:sign_out) { browser.link(:text,'Sign out') }
element(:my_account) { browser.link(:text,'My Account') }
def logged_in?
user_panel.exists? && !sign_in.exists?
end
end
end
With this filter defined then the following code would throw an exception given the user is not logged in:
Google.new do |google|
google.home_page do |hp|
hp.sign_out.click
end
end
The exception would look something like:
Taza::FilterError Exception: logged_in? returned false for sign_out
This means that filters should return true or false.
Problems:
NOTE: This bug does not exist on the latest revision on Github
Currently filters cannot access methods that are already filtered. That is to say that the following piece of code will fall into infinite recursion:
module Google
class HomePage < Taza::Page
filter :logged_in?, :sign_out, :my_account
element(:user_panel) { browser.div(:id,‘guser’) }
element(:sign_in) { browser.link(:text,‘Sign in’) }
element(:sign_out) { browser.link(:text,‘Sign out’) }
element(:my_account) { browser.link(:text,‘My Account’) }
def logged_in?
sign_out.exists? # sign_out is already filtered so when sign_out is called here it will call logged_in? :P
end
end
end
</code







