Implicit Wait
// Set Implicit Wait for 10 seconds
[Link]().timeouts().implicitlyWait([Link](10));
[Link]("[Link]
// WebDriver will Wait up to 10 seconds for Element to Appear
WebElement element = [Link]([Link]("Login"));
[Link]();
Explicit Wait
// Explicit Wait : Wait Up to 15 seconds for Specific Condition
WebDriverWait wait = new WebDriverWait(driver, [Link](15));
// Wait Until Element is Visible
WebElement element =
[Link]([Link]([Link]("Login")
));
[Link]();
Page Load TimeOut Wait
// Set Page Load Timeout to 20 seconds
[Link]().timeouts().pageLoadTimeout([Link](10));
[Link]("[Link] // WebDriver waits for Page to
Load
[Link]("Page loaded successfully!");
SetScript TimeOut Wait
// Set Script Timeout to 15 seconds
[Link]().timeouts().setScriptTimeout([Link](15));
[Link]("[Link]
// Example : Execute an Asynchronous JavaScript
JavascriptExecutor js = (JavascriptExecutor) driver;
[Link]("[Link](arguments[[Link] - 1],
3000);");
[Link]("Async script executed successfully!");
Alert IS Present
[Link]("[Link]
// Trigger an Alert Manually (if applicable)
// Example : Execute an Asynchronous JavaScript
JavascriptExecutor js = (JavascriptExecutor) driver;
[Link]("alert('Test Alert!');");
// Wait for Alert to be Present
WebDriverWait wait = new WebDriverWait(driver, [Link](10));
Alert alert = [Link]([Link]());
[Link]("Alert text : " + [Link]());
[Link](); // Dismiss Alert
Element To Be Selected
[Link]("[Link]
// Locate a Radio Button Element (example)
WebElement radioButton = [Link]([Link]("exampleRadioButtonId"));
// Wait Until Radio Button is Selected
WebDriverWait wait = new WebDriverWait(driver, [Link](10));
[Link]([Link](radioButton));
[Link]("Radio button is selected.");
Element To Be Clickable
[Link]("[Link]
// Wait for Button to be Clickable
WebDriverWait wait = new WebDriverWait(driver, [Link](10));
WebElement button =
[Link]([Link]([Link]("Signup / Login")));
[Link]();
Element Selection State To Be
[Link]("[Link]
// Locate Checkbox Element (example)
WebElement checkbox = [Link]([Link]("exampleCheckboxId"));
// Wait Until Checkbox is Selected
WebDriverWait wait = new WebDriverWait(driver, [Link](10));
[Link]([Link](checkbox, true));