Skip to content

Commit

Permalink
Fixed BaseStepDefinitions so that current page is persistant across s…
Browse files Browse the repository at this point in the history
…teps
  • Loading branch information
alisterscott committed Mar 16, 2011
1 parent 1db59d3 commit 14c5658
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
18 changes: 3 additions & 15 deletions SpecDriver/Pages/BasePageModel.cs
Expand Up @@ -16,29 +16,17 @@ protected BasePageModel(IWebDriver webDriver, By knownElementOnPage)
this.FindKnownElementOnPage(knownElementOnPage); this.FindKnownElementOnPage(knownElementOnPage);
} }



public string Title public string Title
{ {
get get { return driver.Title; }
{
return driver.Title;
}
} }


public IWebDriver Driver public IWebDriver Driver
{ {
get get { return this.driver; }
{ set { this.driver = value; }
return this.driver;
}

set
{
this.driver = value;
}
} }



private void FindKnownElementOnPage(By knownElementOnPage) private void FindKnownElementOnPage(By knownElementOnPage)
{ {
this.Driver.FindElement(knownElementOnPage); this.Driver.FindElement(knownElementOnPage);
Expand Down
14 changes: 11 additions & 3 deletions SpecDriver/StepDefinitions/BaseStepDefinitions.cs
Expand Up @@ -11,9 +11,17 @@ namespace Project1.StepDefinitions
[Binding] [Binding]
public class BaseStepDefinitions public class BaseStepDefinitions
{ {
private const string CurrentPageKey = "Current.Page";
public static IWebDriver Driver { get; set; } public static IWebDriver Driver { get; set; }
protected GoogleHomePageModel GoogleHomePage { get; set; } protected GoogleHomePageModel GoogleHomePage
protected GoogleSearchResultsPageModel GoogleSearchResultsPage { get; set; } {

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.