check a text is before or after another text

Useful to check text order or sorting in a web table
Can you check this doesn't cause infinite loops when `$elementBefore` is on the top level, presumably `<body>`? What's the advantage of doing this over simply calling `getText()` on the root element? Its probably worse for performance to do the `getText()` call on successively larger elements rather than simply once on body.