Wednesday, June 18, 2025

Choosing aspect worth from drop down record with selenium utilizing POM


I am attempting to make a easy check to register in web site – https://www.midomi.com/. I am utilizing c# and selenium however have caught in choosing values from a dropdown record utilizing Web page object mannequin. My undertaking comprises check class and web page object folder with two courses inside her – residence web page and register web page.

Register web page: right here I am having drawback to implement code to choosing values from the dropdown record

namespace MidomiRegisterPOM.PageObject
{
class RegisterPage
{
    non-public IWebDriver driver;

    //kind your electronic mail
    [FindsBy(How = How.Id, Using = "email")]
    [CacheLookup]
    public IWebElement E mail { get; set; }

    //kind your username
    [FindsBy(How = How.Id, Using = "username")]
    [CacheLookup]
    public IWebElement UserName { get; set; }

    //kind your password
    [FindsBy(How = How.Id, Using = "password")]
    [CacheLookup]
    public IWebElement Password { get; set; }

    //affirm your password
    [FindsBy(How = How.Id, Using = "confirm_password")]
    [CacheLookup]
    public IWebElement ConfirmPassword { get; set; }

    //right here choose from dropdown record your beginning day, month and yr       

    //mark privateness discover checkbox
    [FindsBy(How = How.Id, Using = "tos_pp")]
    [CacheLookup]
    public IWebElement PrivacyNotice { get; set; }

    //click on Proceed 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()
    {
        E mail.SendKeys("testing@gmail.com");
        UserName.SendKeys("Tester");
        Password.SendKeys("testing");
        ConfirmPassword.SendKeys("testing");
        ContinueButton.Submit();
    }

I am attempting this however received an error:

Is there any option to choose it with [FindsBy] like I am choosing electronic mail, username and password discipline? Thanks

Right here is my code with out utilizing POM:

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

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

PHP Code Snippets Powered By : XYZScripts.com