0
votes

I am trying to get xpath for following html code, but nothing seems to be working. I appreciate your suggestion. I need to get the xpath based on text.

<label class="label" securityidpath="ACCOUNTS_FS.PART_ACCOUNT_HEADER_FS.PART_ACCOUNT_STATUS" title="Part Account Status">Part Account Status:&nbsp;
</label>

FYI, I tried following variant xpath

  1. //label[normalize-space(text())='Part Account Status:\u00a0']
  2. //label[normalize-space(text())='Part Account Status:\u000a']
  3. //label[normalize-space(text())='Part Account Status:\u202f']

and all the options as per following url https://en.wikipedia.org/wiki/Whitespace_character

Thank You, Yougander

2

2 Answers

1
votes

You can use

/label[normalize-space(text())='Part Account Status:&#160;']

Or use the hexadecimal variant &#x00A0; instead of the decimal &#160;.
Also note that XPath uses slashes (and not backslashes) to define paths, so referencing the root node label would be done by /label. The typo lable instead of label is trivial.

BTW you can avoid the trouble with the entity by using the title attribute in your XPath:

label[normalize-space(@title)='Part Account Status']
1
votes

your element name is wrong and change UTF character name as HexaDecimal entity values:

//label[normalize-space(text())='Part Account Status:&#x00a0;']

XPATH require forward slash