I am using C#, Selenium with the page object model.
I need to understand how to pass a username and password from my test code, into my page object.
Example of my current test below:
[TestMethod]
public void Registeruser()
{
Registrationpage.GoTo();
Registrationpage.Enterusername();
Registrationpage.EnterEmail();
}
Extract from Registration page (page object)
public static void Enterusername()
{
Driver.Instance.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("testusername");
}
public static void Email()
{
Driver.Instance.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("testemail");
}
As you can see, at present i have my entrys in the sendkeys
of my pageobject.
Instead, I want to be able to specify the testusername
and testemail
entrys in my test code so i can vary the text entered on each test.
I understand i need to specify these as strings, but i dont quite understand how to go about this in the pageobject code,I hope this makes sense, any help appreciated ( below is what I want to do)
[TestMethod]
public void Registeruser()
{
Registrationpage.GoTo();
Registrationpage.Enterusername(testusername);
Registrationpage.EnterEmail(testemail);
}