1

I have two buttons("Continue registration") which are identical on two different pages The first one is

<input type="submit" class="button" value="Continue registration">

and the second one is

<a id="confirm-button" href="#" onclick="onSubmit()" class="submit button">Continue registration</a>

I am looking for a way to target both of those elements with one Xpath

Currently I have a solution which works by mapping each of them to one element like this

    [SelectByXPath("//input[@value='Continue registration']")]
    public Button Continue { get; }

    [SelectByXPath("//*[@id='confirm-button']")]
    public Button ContinueWithId { get; }

I can also map the first one by cssSelector and the second one by Id which works perfectly, but ideally I would like to have something like this

    [SelectByXPath("//input[@value='Continue registration'] and *[@id='confirm-button']")]
    public Button Continue { get; }

which basically says find this element by value or by Id whichever is present on the page.

  • Like this? https://stackoverflow.com/questions/5350666/xpath-or-operator-for-different-nodes – DavidG Jan 20 '21 at 11:14

1 Answers1

0

If you want to combine two predicates try

"//*[@value='Continue registration' or @id='confirm-button']"

This will fetch both link and input node

JaSON
  • 4,843
  • 2
  • 8
  • 15