79541298

Date: 2025-03-28 11:32:31
Score: 0.5
Natty:
Report link

I was able to make the test pass with this code:

boolean result = false;
        
        try {
            WebDriver driver = SeleniumSession.get().getWrappedDriver();
            ArrayList<String> handles = new ArrayList<String>(driver.getWindowHandles());
            
            int i = 0;
            for (String handle : handles) {
                if(i == 1 ) {
                    driver.switchTo().window(handle);
                    Alert alert  = driver.switchTo().alert();
                    alert.accept();
                    result = true;
                }
                
                i++;
            }         
        } catch(TimeoutException | UnhandledAlertException e) {
            result = true;
        }

I don't like it, because I have to wait 160 seconds for the timeout to be thrown, but so far that's the only way to handle it.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Tisaja