I’m trying to make simple test to register in website – https://www.midomi.com/. I’m using c# and but have stuck in values from dropdown 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 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("[email protected]");
        UserName.SendKeys("Tester");
        Password.SendKeys("testing");
        ConfirmPassword.SendKeys("testing");
        ContinueButton.Submit();
    }

I’m trying this but got error:
enter image description here

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 :

    var birthMonth = driver.FindElement(By.Id("birth_month"));
    var selectMonth = new SelectElement(birthMonth);
    selectMonth.SelectByValue("5");



Source link https://sqa.stackexchange.com/questions/34396/selecting--value-from--down-list-with-selenium-using-pom

LEAVE A REPLY

Please enter your comment!
Please enter your name here