Selenium IDE - 如何处理java脚本警报和确认 [英] Selenium IDE - How to handle java-script alerts and confirmations
问题描述
我是自动化测试的新手,并已开始使用Selenium IDE作为自动化的选择。
I am novice to automation testing and have started using Selenium IDE as the choice for automation.
我只是想知道是否有任何方法可以处理java-使用IDE的脚本警报。
I just want to know if there is any way to handle java-script alerts using IDE.
采取一个场景:我点击删除按钮,出现一个带有OK和Cancel选项的java脚本警告框,但Xpath可以另一方面,当我在删除按钮上为click事件创建一个脚本并使用Selenium IDE运行它时,该元素会自动删除。
Take a scenario: I am clicking on "Delete" button and there comes a java-script alert box with OK and Cancel options, but Xpath can not identified for these elements.On the other hand, when I make a script for click event on delete button and run it using Selenium IDE, the element gets automatically deleted.
所以,伙计们请帮忙。如果我的问题需要详细说明,请留下答复。
So, guys please help. Leave a reply in case my question needs to be elaborated.
提前致谢。
推荐答案
查看文档。主要部分是:
在Selenium下运行时,JavaScript弹出窗口不会出现。这个
是因为函数调用实际上是在Selenium自己的JavaScript运行时被
覆盖的。但是,仅仅因为你看不到
弹出窗口并不意味着你不必处理它。要处理
弹出窗口,必须调用其assertFoo(模式)
函数。如果你没有
断言存在弹出窗口,你的下一个命令将被阻止,
你将得到类似于以下的错误
When running under Selenium, JavaScript pop-ups will not appear. This is because the function calls are actually being overridden at runtime by Selenium’s own JavaScript. However, just because you cannot see the pop-up doesn’t mean you don’t have to deal with it. To handle a pop-up, you must call its
assertFoo(pattern)
function. If you fail to assert the presence of a pop-up your next command will be blocked and you will get an error similar to the following
[error] Error: There was an unexpected Confirmation! [Chose an option.]
这篇关于Selenium IDE - 如何处理java脚本警报和确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!