Dymond
Dymond

Reputation: 2277

Click element by textvalue with Page Object

Is it possible to click a element by the value with the Page Object function?

I have use the Page Object with Id and Xpath before but never with the inside html.

This is my html:

<div class="col-xs-4 ng-scope">
    <label class="btn btn-radio">
        <input type="radio" name="product" value="5" class="hidden>
        <span class="h3 text-uppercase ng-binding">FASTPRIS</span>
        <small class="text-normal ng-binding">samtal</small>
    </label>
</div>

And was thinking something like this

[FindsBy(How = How.**innerHTML**, Using = "FASTPRIS")]
        public IWebElement btnFastPris { get; set; }

But innerHTML oblivious doesn't exist.

Is there anyway this can be done?

Upvotes: 1

Views: 273

Answers (1)

alecxe
alecxe

Reputation: 473843

Use the xpath expression to check the element's text:

FindsBy(How = How.XPath, Using = "//span[.='FASTPRIS']")

Upvotes: 1

Related Questions