如何与Mink,Selenium 2和Behat的弹出窗口交互? [英] How do I interact with a popup window with Mink, Selenium 2, and Behat?

查看:107
本文介绍了如何与Mink,Selenium 2和Behat的弹出窗口交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与Behat一起浏览内部站点,并且在大多数情况下,它运行得非常好.但是问题是,在网站的某些部分上,我们弹出了一些窗口来完成某项操作.在这种情况下,我们点击撤回"按钮,然后弹出一个对话框,供您选择原因并保存.

I am running through an internal site with Behat and for the most part it is going really well. But the problem is that on certain parts of the site we have popup windows that come up to complete an action. In this case we hit a "Withdraw" button and a popup comes up to have you select a reason and save it.

在理想的世界中,如果我确实设计了此应用程序,则该站点将不会使用任何弹出窗口.但是我是应该实施自动化功能测试的新人(并且我正在从头开始学习如何执行此功能).因此,目前我对站点设计还没有任何发言权(不过随着时间的推移,我会进行很多更改).

In an ideal world, and if I had actually designed this app, the site wouldn't be using any popup windows. But I am the new guy who is supposed to implement automated functional tests (and I am learning how to do that from the ground up). So I don't really have any say over the site design at this point (though I will push for a lot of changes as time goes by).

我正在Ubuntu 12.10系统上使用Mink和Selenium 2驱动程序运行Behat(最终将不得不在Windows环境中运行某些测试以在IE中进行测试).我还将PhantomJS用于已设置的一些测试.

I am running Behat with Mink and the Selenium 2 driver on an Ubuntu 12.10 system (will eventually have to run some tests on a Windows environment for testing in IE). I am also using PhantomJS for some of the tests I have setup.

无论如何,Behat/Mink是否支持通过Selenium 2驱动程序(或通过PhantomJS)使用弹出窗口?我在所有这些自动化设置中都还很早,实际上我只是在尝试工具.如果有更好的工具可以解决此问题,请告诉我.

Anyway, does Behat/Mink support working with popup windows somehow through the Selenium 2 driver (or through PhantomJS)? I am early in all of this automation setup and really I am just experimenting with tools. If there is a better tool that can handle this then please let me know.

我的主要问题是如何使Behat/Mink与弹出窗口配合使用,选中一个框,填写一个字段,然后单击保存"按钮?我知道如何做所有事情,除了让它直接与新弹出的窗口进行交互.任何想法/建议都将受到欢迎.

My primary question is how do I get Behat/Mink to work with the popup window, check a box, fill in a field, and click the save button? I know how to do everything except get it to interact directly with the newly popped up window. Any ideas/suggestions would be welcome.

谢谢!

推荐答案

因此,事实证明Mink包含一些窗口切换功能,但无法识别所述窗口.因此,我编写了两个函数getWindowName()和getWindowNames(),分别标识当前窗口和所有打开的窗口.我将这些更改提交给了GitHub中的项目,看来我的修正很快就会在代码库中实现.

So it turns out that Mink includes some window switching features, but no way to identify said windows. So I wrote two functions getWindowName() and getWindowNames() that identify the current window and all open windows respectively. I committed these changes to the project in GitHub it seems that my fixes will get implemented soon into the code base.

但是通过这些更改,我可以切换Windows了.

But with these changes I am able to switch windows no problem.

链接: https://github.com/Behat/Mink/pull/341

这篇关于如何与Mink,Selenium 2和Behat的弹出窗口交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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