Created
May 4, 2012 03:18
-
-
Save ksummerlin/2591717 to your computer and use it in GitHub Desktop.
Example SlowLoadableComponent page object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Diagnostics; | |
using OpenQA.Selenium; | |
using OpenQA.Selenium.Support.PageObjects; | |
using OpenQA.Selenium.Support.UI; | |
using Selenium.ExtJs.Support.Locators; | |
public class CustomerProgramsPageObject : | |
SlowLoadableComponent<MembershipProgramsPageObject> | |
{ | |
[FindsBy(How = How.XPath, Using = "//button/div[contains(text(),'Add a program')]")] | |
IWebElement addProgramButton = null; | |
public ProgramWizardPageObject AddNewProgram() | |
{ | |
this.Load(); | |
addProgramButton.Click(); | |
return new ProgramWizardPageObject(WebDriver); | |
} | |
private const string expectedTitle = "Customer programs"; | |
protected override bool EvaluateLoadedStatus() | |
{ | |
this.WaitUntilBlockUIFadesOut(); | |
if ((WebDriver.Title != expectedTitle)) { | |
UnableToLoadMessage = string.Format("Invalid title. Expected title: {0}. Actual title: {1}", expectedTitle, WebDriver.Title); | |
return false; | |
} | |
var elements = WebDriver.FindElements(ByExtjs.Query( | |
"h2.ui-pages-header span:nodeValue(Customer programs)")); | |
if (elements.Count == 0) { | |
UnableToLoadMessage = "Customer programs container is not displayed yet"; | |
return false; | |
} | |
//Once we get all the way through the IsLoaded(), then we can initialize the page object | |
PageFactory.InitElements(WebDriver, this); | |
return true; | |
} | |
protected override void ExecuteLoad() | |
{ | |
//no-op because there is no way to naturally 'navigate' because this represents a component <div/> on a page | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment