Tag: 黄瓜

如何使用多行字符串示例比较Cucumber步骤中的xml输出?

Chargify在他们的文档中有这个Cucumber场景。 Scenario: Retrieve a customer via my reference id (as an integer or simple string) Given I have a customer with these attributes | reference | first_name | last_name | email | | 7890 | Joe | Blow | joe@example.com | When I send a GET request to https://[@subdomain].chargify.com/customers/lookup.xml?reference=7890 Then the response status should be […]

耙黄瓜和耙子规格总是使用“开发”环境

我运行Cucumber和RSpec测试的rake任务总是使用我的development环境。 以下是相关的配置文件: RAILS_ROOT/config/environments/cucumber.rb # Edit at your own peril – it’s recommended to regenerate this file # in the future when you upgrade to a newer version of Cucumber. # IMPORTANT: Setting config.cache_classes to false is known to # break Cucumber’s use_transactional_fixtures method. # For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165 config.cache_classes = true # Log error […]

使用Watir-Webdriver测试已打开浏览器

我不想通过@browser = Watir :: Browser.new(:ie)打开一个新的浏览器,但我想使用Watir-Webdriver手动打开浏览器。 我该怎么办? 我认为它可能类似于这个浏览器(:title =>“浏览器标题”)。text_field(:id =>’Field Id’)。set’abc’ 好像我需要创建一个浏览器类的对象来工作..请指导我?

黄瓜嵌入截图不链接到屏幕截图

来自Cukes Google Group的交叉发布: 我已经尝试了许多保存屏幕截图的方法,但确定了内置于watir-webdriver的方法。 无论我使用哪种方法,我都无法在Cucumber HTML报告中成功嵌入此图像的链接。 在c:\ ruby​​ \ cucumber \ project_name \ features \ support \ hooks.rb中,我正在使用: After do |scenario| if scenario.failed? @browser.driver.save_screenshot(“screenshot.png”) embed(“screenshot.png”, “image/png”) end end 带有文本“屏幕截图”的链接添加到报表中,但URL是项目目录路径(“c:\ruby\cucumber\project_name”)而不是文件的直接链接(“c:\ruby\cucumber\project_name\screenshot.png”) 。 我尝试了许多不同的图像格式和使用Dir.pwd的直接路径,每次都有相同的结果。 我错过了什么? 谢谢 Windows XP Ruby 1.8.7 watir-webdriver(0.2.4)黄瓜(0.10.3)

如何使用watir滚动网页

我正在尝试滚动网页以查找并单击滚动页面时延迟加载的内容。 我正在使用以下命令 require ‘watir-webdriver’ @browser = Watir::new :firefox @browser.send_keys :space 我正在使用firefox的web驱动程序,我在ubuntu但它不工作。 在下面的ruby代码中,我试图向下滚动页面,直到我找不到带有:id的元素。 该元素懒洋洋地加载。 我几秒后就会超时,不知道下面的代码有什么问题。 When /^deal (\d+) is loaded$/ do |id| (0..5).each do |click| @browser.send_keys :space end end 使用watir-driver滚动页面的最佳方法是什么?

无法运行Jenkins Build – bundle:“找不到命令”

我目前正在尝试为我的一些黄瓜任务运行jenkins构建。 我所有的gem都是使用Bundler安装的。 gem存储在vendor文件夹中。 但是,当我尝试在执行shell构建步骤中运行bundle install –deployment时,我收到以下错误: Started by user anonymous Building in workspace /Users/Shared/Jenkins/Home/jobs/cukes/workspace [workspace] $ /bin/sh -xe/var/folders/zz/zyxvpxvq6csfxvn_n0000004000001/T/hudson4461284045505361460.sh + bundle install –deployment /var/folders/zz/zyxvpxvq6csfxvn_n0000004000001/T/hudson4461284045505361460.sh: line 2: bundle: command not found Build step ‘Execute shell’ marked build as failure Finished: FAILURE 这真让我抓狂! 它在我的本地机器上运行没有问题。 jenkins为什么看不到我的gem? 任何帮助都会很棒! 干杯,乔恩

Cucumber / Capybara vs Selenium?

前几天,我向我公司的一位测试人员展示了我用黄瓜写的一些测试(2个function,5个场景)。 然后他问了我无法回答的问题: 这比selenium或任何其他function测试录音工具更好吗? 我知道黄瓜是一种不同的技术,它处于不同的测试水平,但我不明白为什么我应该费心去编写和维护Cucumber / Capybara测试。 有人可以给我一个合理的解释,使用Cucumber / Capybara而不仅仅是Selenium吗?

断言在Cucumber中抛出了一个特殊的exception

脚本 我正在写一个库(没有Ruby on Rails),我想要非常详细的Cucumberfunction。 这尤其包括描述在各种情况下应该抛出的错误/exception。 例 编写Cucumber步骤最直观的方法可能就是这样 When I do something unwanted Then an “ArgumentError” should be thrown 问题 我必须解决两个问题: 抛出exception时,第一步不应该失败。 第一步抛出的exception应该可以被第二步访问,以便做一些断言魔术。 不雅和繁琐的解决方案 我能够提出的最好方法是在第一步中缓存exception并将其放入第二步可以访问的实例变量中,如下所示: When /^I do something unwanted$/ do begin throw_an_exception! rescue => @error end end Then /^an “(.*)” should be thrown$/ do |error| @error.class.to_s.should == error end 但是,在我不希望它失败的情况下,这使得第一步或多或少无用,并且它需要一个实例变量,这绝不是一件好事。 那么,任何人都可以帮助我解决至少不那么麻烦的解决方案吗? 或者我应该以不同的方式编写我的function? 任何帮助将非常感激。

有没有人想出办法在多个浏览器/网络驱动程序上运行相同的黄瓜方案?

我正在使用黄瓜+水豚进行一些网络自动化测试。 我希望能够连接我自己的标签(类似于场景之前的@all_browsers)并让它针对我设置的网络驱动程序列表运行(快速,firefox上的selenium,即Chrome和Chrome)。 我不想在前面用4个不同的标签写4个不同时间的场景。 我试着通过我注册的新驱动程序来尝试这样做: Capybara.register_driver :all_browsers do |app| # What would even work in here? I don’t think anything will. end 然后跟进: Before(‘@all_browsers’) do # Same problem here. end 但是我不太确定要放入哪种方法可能会有效。 我尝试过使用黄瓜钩,特别是: Around(‘@all_browsers’) do |scenario, block| Capybara.current_driver = :selenium_firefox block.call Capybara.current_driver = :selenium_chrome block.call # etc end 但这并不像我希望的那样。 它使用相同的驱动程序并使用它运行场景两次。 沿着钩线,这是黄瓜文件中的这个: You may also provide an AfterConfiguration […]

菠菜与黄瓜对于轨道中的BDD

我是从BDD开始的。 想知道从黄瓜或菠菜开始哪个更好。 我的印象是菠菜是新的。 看这里 我应该从哪一开始。 标准是 – 全面支持。 灵活使用 第三方工具和API集成。 再一次,它可能是新手的无知问题:水豚在哪里适合图片。