fix(tests): Only set the autofocus timeout if the element to be focused is hidden.

If the element is already visible, only attempt one focus.

fixes #1329