Permalink
Browse files

Fixed BaseStepDefinitions so that current page is persistant across s…

…teps
  • Loading branch information...
1 parent 1db59d3 commit 14c565803efe128b12be5b1362fe5866db59096c @alisterscott committed Mar 16, 2011
Showing with 14 additions and 18 deletions.
  1. +3 −15 SpecDriver/Pages/BasePageModel.cs
  2. +11 −3 SpecDriver/StepDefinitions/BaseStepDefinitions.cs
@@ -16,29 +16,17 @@ protected BasePageModel(IWebDriver webDriver, By knownElementOnPage)
this.FindKnownElementOnPage(knownElementOnPage);
}
-
public string Title
{
- get
- {
- return driver.Title;
- }
+ get { return driver.Title; }
}
public IWebDriver Driver
{
- get
- {
- return this.driver;
- }
-
- set
- {
- this.driver = value;
- }
+ get { return this.driver; }
+ set { this.driver = value; }
}
-
private void FindKnownElementOnPage(By knownElementOnPage)
{
this.Driver.FindElement(knownElementOnPage);
@@ -11,9 +11,17 @@ namespace Project1.StepDefinitions
[Binding]
public class BaseStepDefinitions
{
+ private const string CurrentPageKey = "Current.Page";
public static IWebDriver Driver { get; set; }
- protected GoogleHomePageModel GoogleHomePage { get; set; }
- protected GoogleSearchResultsPageModel GoogleSearchResultsPage { get; set; }
-
+ protected GoogleHomePageModel GoogleHomePage
+ {
+ get { return (GoogleHomePageModel)ScenarioContext.Current[CurrentPageKey]; }
+ set { ScenarioContext.Current[CurrentPageKey] = value; }
+ }
+ protected GoogleSearchResultsPageModel GoogleSearchResultsPage
+ {
+ get { return (GoogleSearchResultsPageModel)ScenarioContext.Current[CurrentPageKey]; }
+ set { ScenarioContext.Current[CurrentPageKey] = value; }
+ }
}
}

0 comments on commit 14c5658

Please sign in to comment.