I initially tried just waiting for the message div to be visible, but was still getting selenium errors. Waiting for the div to appear before returning it seems to work, though.