在Selenium WebDriver(Selenium 2)中处理警报 [英] Handling Alert in Selenium WebDriver (Selenium 2)

查看:98
本文介绍了在Selenium WebDriver(Selenium 2)中处理警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

driver.findElement(By.xpath("//input[@value='添加']")).click(); 
//Pops out an Alert and program stops, does not continue 

如何单击

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

啊啊啊啊  怎么没有人呢? (TRANS: ahahahahaha why there is no one here to reply my post?)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我顶  (TRANS: Let me promote this post!)


推荐答案

最新的硒2版本,可以做到这一点(至少使用FirefoxDriver):

As of the latest selenium 2 release, this can be done (at least using the FirefoxDriver):

    driver.switchTo().alert().accept();

这篇关于在Selenium WebDriver(Selenium 2)中处理警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆