Flakiness fix when checking for displayed element

Made a change to combat flakiness when checking for an element to be displayed