[refactor] Minor test speedup

This is a function that's called fairly often, it seems. This change cuts the number of packets sent to the browser in half for this function if the element is not present on the page (and perhaps decreases the chances of spurious failure)
Merge pull request #389 from mattbasta/patch-2

[refactor] Minor test speedup