Created
October 14, 2013 21:04
-
-
Save FriendlyTester/6982183 to your computer and use it in GitHub Desktop.
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
//Inherit the DefaultPage. | |
public class BlogObject : DefaultPage | |
{ | |
//Two parameters, base in your driver, and also the timeout for the page to finish loading. | |
public BlogObject(IWebDriver webDriver, double timeout) | |
: base(webDriver) //Pass the driver to the base class. | |
{ | |
//Initiate the locators dictionary, and assign to private parameter. | |
_locators = Locators(); | |
//Wait for an element on the page, adds a level of stability to the object. | |
//Ensure its something specific to that page. | |
WebDriverWait waitForPopup = new WebDriverWait(WebDriver, TimeSpan.FromSeconds(timeout)); | |
waitForPopup.Until(d => d.FindElement(_locators["AuditPopup"])); | |
//Do an assertion to check that you are on the expected page. | |
Assert.AreEqual("Audit Log", WebDriver.FindElement(_locators["lblTitle"]).Text); | |
} | |
private Dictionary _locators; | |
//Store all the required element identifies in a dictionary. | |
//Easier to maintain. | |
private Dictionary Locators() | |
{ | |
Dictionary locators = new Dictionary(); | |
locators.Add("AuditPopup", By.CssSelector("div[class=\"ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable ui-dialog-fixed\"]")); | |
locators.Add("lblTitle", By.Id("ui-dialog-title-1")); | |
locators.Add("btnXClose", By.CssSelector("span[class=\"ui-icon ui-icon-closethick\"]")); | |
locators.Add("btnClose", By.TagName("button")); | |
locators.Add("tblSummary", By.TagName("table")); | |
return locators; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment