cheezy / page_navigation

Provides basic navigation through a collection of items that use the PageObject pattern.
MIT License
10 stars 7 forks source link

Starting continue_navigation_to method from the next page from current #2

Closed gabyshev closed 11 years ago

gabyshev commented 11 years ago

At the moment continue_navigation_to starting navigation from current page. For instance:

PageObject::PageFactory.routes = {default: [[Page1, :method1], [Page2, :method2, "data"], [Page3, :method3]]} 

And if I use that route:

navigate_to(Page2).method2 "other_data"
continue_navigation_to(Page3).method3

The test start from Page2 and rerun method2 with "data" that I don't want to use in this case.

Maybe it would be better if continue_navigation_to method will start from the next page from current? So I won't lose "other_data" Or if I do a mistake, please point it to me.

cheezy commented 11 years ago

A couple of my colleagues and I went back and forth on where continue_navigation_to should begin before we landed on where we are. Here are a couple of suggestions:

If you frequently pass "other_data" then you could simply add a new route that does this. In order to use the second route you would simple call navigate_to like this:

navigate_to(Page3, :using => :the_other_route)

Another possibility is to use the navigate_to method in the second step instead of the continue_navigation_to method. navigate_to has another optional parameter which is the :from key. You could do something like this:

navigate_to(Page2).method2 "other_data"
navigate_to(Page3, :from => Page3).method3

The :from options is designed to allow you to use portions of routes. It gives you to ability to weave portions of different routes together as well.

Another option (a hack) is to simply set the @current_page instance variable. continue_navigation_to looks at that variable to determine where to begin.