2

I'm trying to find an input box which is next to a label 'Organisation Id'. As the identification properties of the inputbox change every build I was thinking I could serach for the label text then go up level to the immediate parent then come down to the inputbox. I have tried similar xpath queries to the code below but haven't been able to successfully identify the object without using the id of the object which will always change. Any ideas on how to construct an xpath query to do this would be appreciated.

I have tried the following code but it is not even finding the label field

//label[contains(text(),'Organisation Id')]/following::input[1]

HTML:

enter image description here

Mathias Müller
  • 22,203
  • 13
  • 58
  • 75
user3803807
  • 285
  • 4
  • 18
  • 2
    Provide the HTML code please. – Newcomer Jan 19 '16 at 12:22
  • Replace `text()` with a dot – see [this answer](http://stackoverflow.com/a/3655588/733637) to [XPath contains(text(),'some string') doesn't work when used with node with more than one Text subnode](http://stackoverflow.com/questions/3655549/xpath-containstext-some-string-doesnt-work-when-used-with-node-with-more). – CiaPan Jan 19 '16 at 12:41
  • Please show a [complete sample of the HTML document you are selecting from](http://stackoverflow.com/help/mcve). Replacing `text()` with `.` is not the answer, and neither does the post below answer the question. – Mathias Müller Jan 19 '16 at 13:10

1 Answers1

1

Try this XPath

//label[contains(text(),'Organisation Id')]/following-sibling::input

XPath Axes

Alex Kopachov
  • 723
  • 4
  • 9
  • This answer does not make any difference given the document and on top of that, there is no explanation for this meaningless change. – Mathias Müller Jan 19 '16 at 13:22