Refactored the representation of the matching element in WebAssert

This reduces duplication of the logic needed to handle array selectors and
improves the exception message when the named selector is used.