Created
February 19, 2017 12:14
-
-
Save angelovstanton/6c5d9340ffe63482329ca771a952af70 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 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