Make wait-for-request method more robust in selenium tests

Change-Id: I10cf604e8fa1ae4e75c1c0cb3f7a55ff158f1623