Step one would be to tell development to make the html more automation friendly, because this is pretty awful. :) I hope you have good persuasion skills.
You can probably clean this up, but here is an example using both contains and text()= for getting the text element.
"//*[@id='summaryDiv']/table[4]//text()[following-sibling::b[contains(text(), 'Unit Numb')] and preceding-sibling::b[text()='Rel#:']]"
The important thing to remember here, is that even though you don't see a tag around some of the text, text()
itself can work to find those text() elements, as if it was a normal tag.
While following and preceding may look a bit backwards here, it essentially means look for some text before the 'b' node text that contains 'Unit Numb' and after the 'b' node text that is 'Rel#:'.
This should give you the number with some extra white space, but you can trim it and parse it from there.
br
andtext()
nodes that don't have clear attributes.