When the page load is slow, it is recommended to use the display wait: Wait until the element that needs to be loaded succeeds and then manipulate the element without waiting for other elements to load
webdriverwait wait = new webdriverwait (driver, 10);
Wait.until (expectedconditions.visibilityofelementlocated (by.id ("kw"));
Explicitly waiting to use the Expectedconditions class in the self-contained method, you can make a trial wait for the judgment.
Explicitly waiting for a condition that can be customized for more complex page-waiting conditions
(1) Whether the page element is available on the page and can be clicked: Elementtobeclickable (by locator)
(2) The page element is selected: elementtobeselected (webelement Element)
(3) page elements exist in the page: presenceofelementlocated (by locator)
(4) Whether a specific text is included in the page element: Texttobepresentinelement (by locator)
(5) page element value: Texttobepresentinelementvalue (by locator, java.lang.String text)
(6) Title: Titlecontains (java.lang.String title)
The test code will continue to execute the subsequent test logic backwards only if the condition satisfies the explicit wait
If the maximum explicit wait time threshold is exceeded, the test program throws an exception.
webdriverwait wait = new webdriverwait (driver,5);
Wait.until (expectedconditions.presenceofelementlocated (By.cssselector (")));
Selenium webdriver Display wait time