Selenium webdriver 如何使用selenium捕获gmail生成的alertbox

Selenium webdriver 如何使用selenium捕获gmail生成的alertbox,selenium-webdriver,gmail,alert,browser-automation,Selenium Webdriver,Gmail,Alert,Browser Automation,WebDriverWait wait=新的WebDriverWait(驱动程序,持续时间秒(10)); 布尔逻辑存在 try { wait.until(ExpectedConditions.alertIsPresent()); alertExists = true; } catch(Exception e) { alertExists = fal

WebDriverWait wait=新的WebDriverWait(驱动程序,持续时间秒(10)); 布尔逻辑存在

        try
        {
            wait.until(ExpectedConditions.alertIsPresent());
            alertExists = true;
        }
        catch(Exception e)
        {
            alertExists = false;
        }
        if(alertExists)
        {
            //do stuff
          
        }
        else
        {
            //do other stuff
          
        }
我正在使用此代码,我也尝试了其他方法,但它不起作用…请帮助