Created
February 19, 2017 12:17
-
-
Save angelovstanton/580072affd49275265dfd5985dffcc47 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
public class ResourcesPage | |
{ | |
private readonly IWebDriver driver; | |
private readonly string url = @"https://automatetheplanet.com/resources/"; | |
public ResourcesPage(IWebDriver browser) | |
{ | |
this.driver = browser; | |
PageFactory.InitElements(browser, this); | |
} | |
public string Url => this.url; | |
[FindsBy(How = How.Id, Using = "emailId")] | |
public IWebElement Email { get; set; } | |
[FindsBy(How = How.Id, Using = "nameId")] | |
public IWebElement Name { get; set; } | |
[FindsBy(How = How.Id, Using = "downloadBtnId")] | |
public IWebElement DownloadButton { get; set; } | |
[FindsBy(How = How.Id, Using = "successMessageId")] | |
public IWebElement SuccessMessage { get; set; } | |
public IWebElement GetGridElement(string productName, int rowNumber) | |
{ | |
var xpathLocator = string.Format("(//span[text()='{0}'])[{1}]/ancestor::td[1]/following-sibling::td[7]/span", productName, rowNumber); | |
return this.driver.FindElement(By.XPath(xpathLocator)); | |
} | |
public void Navigate() => this.driver.Navigate().GoToUrl(this.url); | |
public void DownloadSourceCode(string email, string name) | |
{ | |
this.Email.SendKeys(email); | |
this.Name.SendKeys(name); | |
this.DownloadButton.Click(); | |
var successMessage = string.Format("Thank you for downloading {0}! An email was sent to {1}. Check your inbox.", name, email); | |
var waitElem = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); | |
waitElem.Until(ExpectedConditions.TextToBePresentInElementLocated(By.Id("successMessageId"), successMessage)); | |
} | |
public void AssertSuccessMessage(string name, string email) | |
{ | |
var successMessage = string.Format("Thank you for downloading {0}! An email was sent to {1}. Check your inbox.", name, email); | |
Assert.AreEqual(successMessage, this.SuccessMessage.Text); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment