assertXpath: Check array length prior to array access

This prevents the error "Element at position [1] doesn't exist in array" if xmlSearch didn't return any results and a text for comparison was passed.