Skip to content

Instantly share code, notes, and snippets.

@rainchen
Created November 6, 2009 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rainchen/227990 to your computer and use it in GitHub Desktop.
Save rainchen/227990 to your computer and use it in GitHub Desktop.
# Cucumber helper for multiple forms in one page by RainChen @ 2009-11-06
# more detail: http://hi.baidu.com/rainchen/blog/item/dfad7931f77e2413ebc4afc1.html
# select a form as current scope
When /^I focus on the form which "([^\"]*)" is "([^\"]*)"$/ do |attr, value|
selector = "form[@#{attr}='#{value}']"
# within using: Webrat::XML.css_at(@scope.dom, @selector)
# p webrat_session.within("form[@action='/pages/search']") {|scope| scope.dom }
# xpath_search requried ".//" , for example:
# Webrat::XML.xpath_search(webrat_session.current_scope.dom, ".//form[@action='/pages/search']")
# when found, webrat_session.current_scope.dom.object_id should be changed
webrat_session.scopes.push(Webrat::Scope.from_scope(webrat_session, webrat_session.current_scope, selector))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment