Getting Selenium to pause for X seconds

You can locate an element that loads after the initial page loads and then make Selenium wait until that element is found.

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("ID")));

If you want to delay a certain number of seconds, rather than to respond as soon as possible, here is a function for pause similar to what selenium IDE offers:

public void pause(Integer milliseconds){
    try {
        TimeUnit.MILLISECONDS.sleep(milliseconds);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

source


That wouldnt really be a selenium specific thing. You just want java to sleep for a bit after loading the page but before taking the screenshot.

Thread.sleep(4000);

put that after your driver.get statement.