jeudi 3 novembre 2016

How to use [FindsBy] annotation so that I can resuse the element found to find its inner elements?

The DOM I am working on has lots of nested elements (box inside box structure ) and I am finding it difficult to code using POM design pattern.

I have used FindsBy, FindsByAll, FindsBySequence but it appears that anytime I need to identify inner elements of a container, I will have to include finding the external element/container.

Is there a way to reuse the element 'DimensionPanel' instead of using [FindsBy(How = How.Id, Using = "container-dimpanel")]?

ex:

    [FindsBy(How = How.Id, Using = "container-dimpanel")]
    public IWebElement DimensionPanel { get; set; }

    #region DimensionPanel elements
    [FindsBySequence]
    [FindsBy(How = How.Id, Using = "container-dimpanel")]
    [FindsBy(How = How.Id, Using = "metrics-selector-container")]
    [FindsBy(How = How.TagName, Using = "a")]
    public IWebElement MetricsButton { get; set; }

    [FindsBySequence]
    [FindsBy(How = How.Id, Using = "container-dimpanel")]
    [FindsBy(How = How.Id, Using = "metrics-selector-container")]
    [FindsBy(How = How.TagName, Using = "span")]
    public IWebElement MetricsCount { get; set; }
    #endregion DimensionPanel elements

Aucun commentaire:

Enregistrer un commentaire