一般会用隐式等待,但是 这个等待只是等待某个元素的可用性
webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
元素可用后,未必可操作,比方还在动画中,此时不可点击, 否则会报告错误:
org.openqa.selenium.WebDriverException:
element click intercepted: Element <button id="submitLogin" type="submit" style="margin-top: 4px!important;" class="btn-theme btn-theme-sm btn-base-bg text-uppercase login-margin-b login-btn">...</button> is not clickable at point (951, 630). Other element would receive the click: <div class="portal-info-wapper" style="display: block;">...</div>
(Session info: headless chrome=101.0.4951.0)
此时就需要用线程休眠来强制等待了.
Thread.sleep(10);