0

When I open a page, an alert is being displayed. I tried to accept it using the below code.

    WebDriver driver = new ChromeDriver();
    driver.manage().window().maximize();
    driver.get("https://www.ultimateqa.com/fake-landing-page/");
    driver.switchTo().alert().accept();

It's not working and got NoAlertPresentException. Then I tried to wait for the alert with the below code.

    WebDriverWait wait= new WebDriverWait(driver, 10);
    Alert alert = wait.until(ExpectedConditions.alertIsPresent());
    alert.accept();

It is still not working and got timeoutException now.

learningQA
  • 641
  • 1
  • 5
  • 20

1 Answers1

1

I have visit the website you provided in the example and have noticed that there is an 'notification' popup not an alert.

Here you can find more information how to handle it:

How to click Allow on Show Notifications popup using Selenium Webdriver

Infern0
  • 2,565
  • 1
  • 8
  • 21