黄瓜 + JavaScript 应用程序中的 Selenium
我正在尝试学习如何最好地使用 Cucumber + Selenium。 在大多数情况下,它似乎非常简单,但我想获得一些有关如何测试对话框的指导。 基本上我需要实现:
assert !60.times{
break if ("Other Income" == @selenium.get_text("//form[@id='new_account']/h3") rescue false); sleep 1 }
标准等待形式。 如何在 Cucumber 规范中实现此目的?
I am trying to learn how to best use Cucumber + Selenium. For the most part it seems to be very straight forward but I would like to get some guidance on how to test dialogs. Basically I need to implement:
assert !60.times{
break if ("Other Income" == @selenium.get_text("//form[@id='new_account']/h3") rescue false); sleep 1 }
A standard wait for form. How do I accomplish this in a Cucumber spec?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要稍微更新这个答案,我强烈建议使用 Capybara:
http://github.com/jnicklas/capybara
只需安装一个
gem
即可使用 javascript!To update this answer a bit, I'd highly recommend using Capybara:
http://github.com/jnicklas/capybara
Being able to use javascript is just a
gem install
away!看看 https://github.com/cucumber/cucumber/wiki/setting- up-selenium 进行了相当彻底的演练,以及 Cucumber 附带的示例(原生示例和通过 webrat 使用 selenium) 。
Look at https://github.com/cucumber/cucumber/wiki/setting-up-selenium for a pretty thorough walkthrough, plus the examples which come with Cucumber (native examples and selenium through webrat).
本指南已过时,即将进行修复,但与此同时您不需要 Selenium gem。 另外,您必须使用 selenium-client -v=1.2.14。 您不需要覆盖任何罐子。 确保所有 selenium 进程都已停止并安装了正确的版本并且它应该运行。 有关硒/非硒测试的多个环境的信息仍然有效且有用。
This guide is out of date, a fix is upcoming but in the meantime you do not need the Selenium gem. Also, you must use selenium-client -v=1.2.14. You do not need to overwrite any jars. Make sure all selenium processes are stopped and the correct versions are installed and it should run. The information about multiple environments for selenium/non-selenium tests is still valid and useful.