selenium 三大等待
三大等待方式
硬性等待
thread.sleep(3000)
隐式等待
//隐式等待,超时等待5秒,全局有效
webDriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
显示等待

//显示等待,直到xpath元素出现,会接触等待
WebDriverWait webDriverWait = new WebDriverWait(webDriver,3000);
webDriverWait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"11\"]/div/div/h3/a")));
webDriver.findElement(By.xpath("//*[@id=\"11\"]/div/div/h3/a")).click();

浙公网安备 33010602011771号