This is what worked for me using Explicit Wait from here WebDriver: Advanced Usage
public void checkAlert() {
try {
WebDriverWait wait = new WebDriverWait(driver, 2);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.accept();
} catch (Exception e) {
//exception handling
}
}
More Related Contents:
- How to handle authentication popup with Selenium WebDriver using Java
- How to wait for an alert in Selenium webdriver ? [duplicate]
- Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click
- Is it possible to switch to an element in a frame without using driver.switchTo().frame(“frameName”) in Selenium Webdriver Java?
- Replace implicit wait with explicit wait (selenium webdriver & java)
- When to use explicit wait vs implicit wait in Selenium Webdriver?
- Page scroll up or down in Selenium WebDriver (Selenium 2) using java
- Selenium 2.53 not working on Firefox 47
- Selenium WebDriver How to Resolve Stale Element Reference Exception?
- Using Selenium WebDriver to retrieve the value of an HTML input
- How to handle Pop-up in Selenium WebDriver using Java
- The type FluentWait is not generic; it cannot be parameterized with arguments error for FluentWait Class through Selenium and Java
- Equivalent of waitForVisible/waitForElementPresent in Selenium WebDriver tests using Java?
- Is there a way to use Selenium WebDriver without informing the document that it is controlled by WebDriver?
- org.openqa.selenium.WebDriverException: unknown error: call function result missing ‘value’
- Selenium Webdriver submit() vs click()
- Check if element is clickable in Selenium Java
- java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;) with Selenium, gradle and ChromeDriver
- WebDriverException: unknown error: Runtime.executionContextCreated has invalid ‘context’: while initializing Chrome browser
- What is difference between Implicit wait and Explicit wait in Selenium WebDriver? [duplicate]
- java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V with IE and Selenium through Java
- getWindowHandles() not working in firefox 58.The focus remains on parent tab and does not transfer to next tab
- Test if an element is present using Selenium WebDriver
- Capturing browser logs with Selenium WebDriver using Java
- Why do some elements exist but not interactable/displayed?
- Getting StaleElementReferenceException while trying print the link names
- How to create a executable jar file for Testng and the runnnig point should be the Xml file
- How to upload a file in Selenium with no text box
- How to scroll a specific DIV using Selenium WebDriver with Java?
- UnreachableBrowserException Caused by: java.lang.NullPointerException when “webdriver.firefox.marionette” is used