I’m trying to make a simple test to register in website – https://www.midomi.com/. I’m using c# and selenium but have stuck in selecting values from a dropdown list using Page object model. My project contains test class and page object folder with two classes inside her – home page and register page.
Register page: here I’m having problem to implement code to selecting values from the dropdown list
namespace MidomiRegisterPOM.PageObject
{
class RegisterPage
{
private IWebDriver driver;
//type your email
[FindsBy(How = How.Id, Using = “email”)]
[CacheLookup]
public IWebElement Email { get; set; }
//type your username
[FindsBy(How = How.Id, Using = “username”)]
[CacheLookup]
public IWebElement UserName { get; set; }
//type your password
[FindsBy(How = How.Id, Using = “password”)]
[CacheLookup]
public IWebElement Password { get; set; }
//confirm your password
[FindsBy(How = How.Id, Using = “confirm_password”)]
[CacheLookup]
public IWebElement ConfirmPassword { get; set; }
//here select from dropdown list your birth day, month and year
//mark privacy notice checkbox
[FindsBy(How = How.Id, Using = “tos_pp”)]
[CacheLookup]
public IWebElement PrivacyNotice { get; set; }
//click Continue button
[FindsBy(How = How.Id, Using = “submitLink”)]
[CacheLookup]
public IWebElement ContinueButton { get; set; }
public RegisterPage(IWebDriver driver)
{
this.driver = driver;
PageFactory.InitElements(driver, this);
}
public void RegisterToSite()
{
Email.SendKeys(“testing@gmail.com”);
UserName.SendKeys(“Tester”);
Password.SendKeys(“testing”);
ConfirmPassword.SendKeys(“testing”);
ContinueButton.Submit();
}
I’m trying this but got an error:
Is there any way to select it with [FindsBy] like I’m selecting email, username and password field? Thanks
Here is my code without using POM:
var birthMonth = driver.FindElement(By.Id(“birth_month”));
var selectMonth = new SelectElement(birthMonth);
selectMonth.SelectByValue(“5”);