Update script to wait for the correct element to be invisible.