Try implicit waits - docs here
There is a second type of wait that is distinct from explicit wait
called implicit wait. By implicitly waiting, WebDriver polls the DOM
for a certain duration when trying to find any element. This can be
useful when certain elements on the webpage are not available
immediately and need some time to load.
You set it once for your driver and it's a dynamic wait up until your specified timeout.
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Alternatively, you can use explicit waits per element that needs it:
new WebDriverWait(driver, Duration.ofSeconds(30)).until(ExpectedConditions.elementToBeClickable(<<Your-Identifier>>));
With explicit waits you can ensure certain ExpectedConditions are ready and you control the timeout for the element to synchronise with.
A list of expected conditions for Java are here
It is generally recommended you choose on approach if possible:
Warning: Do not mix implicit and explicit waits. Doing so can cause
unpredictable wait times. For example, setting an implicit wait of 10
seconds and an explicit wait of 15 seconds could cause a timeout to
occur after 20 seconds.