'Click on pop up/ alert to launch web app using selenium

Currently in my tests when i select a button a pop up appears asking me to launch my web application Pop Up

However I cant seem to switch onto this pop up as if its a window

    new WebDriverWait(driver,5).until(ExpectedConditions.numberOfWindowsToBe(2));


    Set<String> allHandles = driver.getWindowHandles();
    for(String winHandle:allHandles)
    {
        if (!first_handle.equalsIgnoreCase(winHandle))
        {
            driver.switchTo().window(winHandle);
        }
    }

And I also attempted to accept it as an alert, but it didnt recognise it as an alert

Alert alert = driver.switchTo().alert();
// Alert present; set the flag
presentFlag = true;
// if present consume the alert
alert.accept();

Ive seen suggestions to disable notifications and they dont work either, my main aim is to select the open button but I cant get any elements to select from the console either



Solution 1:[1]

You may need to disable notifications for a selenium web driver at a WebDriver level by adding options. Here is an example of how to do it for ChromeDriver:

ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-notifications");
System.setProperty("webdriver.chrome.driver", "/home/users/user.user/Desktop/softwares/chromedriver");
WebDriver driver =new ChromeDriver(options);
driver.get("http://your.url/");
driver.manage().window().maximize();
    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lia