Using Thread.sleep(2000);
is an unconditional wait. If your test loads faster you will still have to wait. So in principle using implicitlyWait
is the better solution.
However, I don't see why implicitlyWait
does not work in your case. Did you measure if the findElement
actually takes two seconds before throwing an exception. If so, can you try to use WebDriver's conditional wait as described in this answer?