I was using POM for initializing my elements as below.

[FindsBy(How = How.XPath, Using = "//ion-buttons[2]/button")]
    public IWebElement SearchIcon { get; set; }

    [FindsBy(How = How.CssSelector, Using = "input.searchbar-input")]
    public IWebElement SearchTextbox { get; set; }

    [FindsBy(How = How.ClassName, Using = "item-wrapper")]
    public IWebElement fixedcontent { get; set; }

But how to use below line of code on above format:

IList<IWebElement> propertyList1 = Setup.driver.FindElements(By.ClassName("name"));

2 Answers 2


In C# you use the following:

[FindsBy(How = How.ClassName, Using = "name')]
private IList<IWebElement> propertyList1 { get; set; }

Btw, notice I've declared the locator as "private". As a general rule you don't make locators in a POM "public".

  • +1 but why add { get; set; }?
    – FDM
    Jun 20, 2017 at 10:04
  • That's C# shorthand for "use the usual accessor methods". There's a good explanation of it here Jun 20, 2017 at 11:02
  • Why would you write them for a private variable? Is there any added value versus private IWebElement element;?
    – FDM
    Jun 20, 2017 at 11:09
  • Your locators should only really be accessed by the page object they belong to. So be default you should always mark them as private unless you have a really good reason not to. Using the propertyList1 example above, lets say you want to get one of the properties in the list. In your page object you would declare a public method that accesses that locator list and then used that method in your test code. You would never access propertyList1 directly in your test. So by declaring it as private you ensure that no one can accidentally do that. Jun 20, 2017 at 11:27
  • 1
    I just realised I misunderstood your question. The solution I gave declares "propertyList1" as a Property were as the example you gave declares "element" as a Field. Other than it being good OOP practice to use encapsulation, I'm not sure there is a huge difference between the two in this case. It's a pretty big topic though. You might want to check out Difference between Property and Field in C# 3.0+ for a more extensive discussion of it. Jun 21, 2017 at 10:12

I am providing my answer in java:

public List<WebElement> propertyList1;


@FindBy(how = How.CLASSNAME, Using=”name”))
public List<WebElement> propertyList1;

Additional Information: We can use @FindAll with multiple @FindBy annotations to look for elements that match any of the given locators:

    @FindBy(how=How.ID, using=”username”),
private WebElement user_name;

I would also recommend to read for future reference.

  • Thanks, But im up to C# dude
    – ChathuD
    Mar 15, 2017 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.