Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created February 19, 2017 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelovstanton/6c5d9340ffe63482329ca771a952af70 to your computer and use it in GitHub Desktop.
Save angelovstanton/6c5d9340ffe63482329ca771a952af70 to your computer and use it in GitHub Desktop.
public class RegistrationPage
{
private readonly IWebDriver driver;
private readonly string url = @"http://www.automatetheplanet.com/register";
public RegistrationPage(IWebDriver browser)
{
this.driver = browser;
PageFactory.InitElements(browser, this);
}
[FindsBy(How = How.Id, Using = "emailId")]
public IWebElement Email { get; set; }
[FindsBy(How = How.Id, Using = "passId")]
public IWebElement Pass { get; set; }
[FindsBy(How = How.Id, Using = "userNameId")]
public IWebElement UserName { get; set; }
[FindsBy(How = How.Id, Using = "registerBtnId")]
public IWebElement RegisterButton { get; set; }
public User RegisterUser(string email = null, string password = null, string userName = null)
{
var user = new User();
this.driver.Navigate().GoToUrl(this.url);
if (string.IsNullOrEmpty(email))
{
email = UniqueEmailGenerator.BuildUniqueEmailTimestamp();
}
user.Email = email;
this.Email.SendKeys(email);
if (string.IsNullOrEmpty(password))
{
password = TimestampBuilder.GenerateUniqueText();
}
user.Pass = password;
this.Pass.SendKeys(password);
if (string.IsNullOrEmpty(userName))
{
userName = TimestampBuilder.GenerateUniqueText();
}
user.UserName = userName;
this.UserName.SendKeys(userName);
this.RegisterButton.Click();
return user;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment