如何使用java中的web驱动程序在selenium中单击按钮时使用警报框

如何使用java中的web驱动程序在selenium中单击按钮时使用警报框,selenium,selenium-webdriver,selenium-ide,Selenium,Selenium Webdriver,Selenium Ide,请帮助我的测试人员,我很沮丧这一点,我已经应用了越来越多的代码,但没有找到解决方案再次和相同的消息显示 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 org.openqa.selenium.UnhandledAlertException:意外模式对话框(文本:已添加到购物列表中的膳食):已添加到购物列表中的膳食 构建信息:版本:“2.53.0”,修订版:“35ae25b”,时间:“

请帮助我的测试人员,我很沮丧这一点,我已经应用了越来越多的代码,但没有找到解决方案再次和相同的消息显示

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 org.openqa.selenium.UnhandledAlertException:意外模式对话框(文本:已添加到购物列表中的膳食):已添加到购物列表中的膳食 构建信息:版本:“2.53.0”,修订版:“35ae25b”,时间:“2016-03-15 16:57:40” 系统信息:主机:'Saurabh',ip:'192.168.3.21',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'1.8.0_65' 驱动程序信息:org.openqa.selenium.firefox.FirefoxDriver 功能[{applicationCacheEnabled=true,rotatable=false,handlesAlerts=true,databaseEnabled=true,version=46.0.1,platform=WINDOWS,nativeEvents=false,acceptSslCerts=true,WebStorage Enabled=true,locationContextEnabled=true,browserName=firefox,takesScreenshot=true,javascriptEnabled=true,CSSSelectorEnabled=true}] 会话ID:87eb9958-85a9-4571-8bbd-663fdaad2ad0

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

希望这有帮助

你需要给予的不仅仅是你所收到的错误。理想情况下,您需要提供触发错误的自动化代码部分,如果可能的话,还需要提供您当时正在测试的代码,以便进行故障排除谢谢您的回复我的问题终于解决了…很有用..请竖起大拇指!!