Tag: 黄瓜

如何在Ruby中获取方法的完全限定名称?

假设我在Ruby的工作区中有一个可用的方法。 是否有我可以使用的命令将恢复该方法的完全限定名称? 我正在寻找类似于Matlab中哪个函数的东西,它为它给出的任何参数返回一个明确的名称。 我问,因为我在Cucumber中编写了一个需要发送特定GET和POST请求的测试。 我在我的工作区中都有get和post方法,但我没有自己导入它们,所以我不知道它们来自哪里。 我想查看这些方法的文档。 为了找到文档,我需要知道它们所定义的模块。我正在尝试获取完全限定的名称,以便找出它们来自哪个模块。

在水豚的多个会话

背景 我想测试我的webapp上的多个用户登录,我使用黄瓜和水豚来做这件事。 我找到了关于如何处理多个会话的这个链接 ,但不幸的是,它看起来不像黄瓜可以找到定义的in_session方法。 我该如何访问它? 黄瓜情景 Given I go to teacher login in Steve’s browser When I enter “Steve” in the username field And I enter “StevesPassword” in the password field And I click login Then I should see “Steve Lastname” as the current user When I go to teacher login in Lisa’s browser And […]

当存在具有相同显示文本的其他链接时,使用Watir单击特定链接

所以我有一张桌子看起来就像那里有书籍清单,在第一栏中有两个链接,查看和删除,每本书。 我希望能够使用Watir找到具有指定书名的行,然后单击该书的该视图按钮。 这是我到目前为止所拥有的 And /^click on View link of “(.*)” on the result set table$/ do |cell_name| cellButton(“submit.view”, cell_name, “”) end # # And /^click on Delete link of “(.*)” on the result set table with no_wait$/ do |cell_name| cellButton(“submit.delete”, cell_name, “no_wait”) end # # def cellButton(submit_type, s_name, s_wait_type) c_found = 0 @browser.tables do |tbl| […]

使用ruby + watir-webdriver + cucumber和parallel_tests gem在多个浏览器中运行测试

目前,我使用cucumber.yml中的并行配置文件加载环境特定文件,使用hooks.rb设置浏览器。 我使用’parallel_cucumber features’运行我的测试。 我的hooks.rb文件中没有太多内容: Before do @browser = Watir::Browser.new :firefox end After do @browser.close end 该配置文件如下所示: parallel: FIG_NEWTON_FILE=local.yml –no-source –color –format pretty 有没有办法更改我的hooks.rb文件,以便所有function都针对一组浏览器(firefox,chrome,safari)运行? 是否可以通过命令行传递文件名或环境?

如何在Cucumber中测试不同的环境(例如开发|测试|生产)?

采取这种情况。 我有一个Google Analytics跟踪代码,我只希望它以生产模式显示。 所以我可能有两个这样的场景: Scenario: Don’t embed tracking code in development or test mode Given the app is not in production mode When I go home Then I should really not see the tracking code Scenario: Embed tracking code in production mode Given the app is in production mode When I go home Then I […]

无法加载这样的文件 – 2.2 / gherkin_lexer_en,如何修复?

我需要一些帮助。 我该如何解决这个问题? 当我调用cucumber我收到以下错误: *** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansic on/) to get coloured output on Windows WARNING: cannot load such file — 2.2/gherkin_lexer_en Couldn’t load 2.2/gherkin_lexer_en The $LOAD_PATH was: lib C:/Ruby22/lib/ruby/gems/2.2.0/gems/cucumber-1.3.19/bin/../lib C:/Ruby22/lib/ruby/gems/2.2.0/gems/builder-3.2.2/lib C:/Ruby22/lib/ruby/gems/2.2.0/gems/diff-lcs-1.2.5/lib C:/Ruby22/lib/ruby/gems/2.2.0/gems/multi_json-1.11.0/lib C:/Ruby22/lib/ruby/gems/2.2.0/gems/gherkin-2.12.2-x86-mingw32/lib […] 系统: Windows 8.1 x64 Ruby 2.2.1安装程序 我得到了答案: https : //github.com/cucumber/cucumber/issues/830#issuecomment-90837546 我担心Windows / Ruby上的Cucumber需要ruby 2.0.0(x86)。 原因是gherkin […]

如何动态地将部分添加到SitePrism页面对象?

我正在使用SitePrism来测试我的Web应用程序。 我有许多扩展SitePrism::Page的类,许多经常使用的HTML片段由扩展SitePrism::Section匹配类表示 class Login < SitePrism::Section element :username, "#username" element :password, "#password" element :sign_in, "button" end class Home < SitePrism::Page section :login, Login, "div.login" end 问题是,我正在处理的应用程序基于CMS,其中可以通过基于预定义内容选择模板然后将任意数量的可用组件拖放到页面上来组装页面。 初始开发人员创建了一个页面对象来镜像每个可用的模板 。 只要测试数量很少并且我们不得不在我们的function文件中测试的页面变体太多,这就没问题了。 随着多个测试用例的增加,页面对象开始以惊人的速度增长。 虽然我们可以通过为CMS中可用的每个组件定义Sections并在页面对象中重用它们来轻松减轻代码重复,但是很多属性很少被使用。 class BlogPost < SitePrism::Page section :logo, MySite::Components::Logo, '.logo' section :navigation, MySite::Components::Navigation, '.primary-navigation' section :header, MySite::Components::BlogHeader, '.header' section :introduction, MySite::Components::Text, '.text .intro' # and so […]

如何使用无头铬与水豚和selenium

Chrome版本:59.0.3071.104 使用Cucumber,Capybara,Selenium实现无头Chrome的自动化测试。 function/支持/ env.rb require ‘rubygems’ require ‘capybara/cucumber’ Capybara.register_driver :selenium_chrome do |app| Capybara::Selenium::Driver.new(app, :browser => :chrome, args: [‘headless’]) end Capybara.default_driver = :selenium_chrome 在进行黄瓜测试时,它说: 警告Selenium [DEPRECATION]:不推荐使用args或:开关。 请改用Selenium :: WebDriver :: Chrome :: Options#add_argument。 使用Headless Chrome的水豚和selenium的正确方法是什么? 谢谢。 编辑1:我尝试使用Ruby-Binding , Capybara和工作示例进行以下操作 。 但它也会产生错误。 require ‘rubygems’ require ‘capybara/cucumber’ require ‘selenium-webdriver’ Capybara.register_driver :selenium_chrome do |app| options = Selenium::WebDriver::Chrome::Options.new options.add_argument(‘–headless’) driver […]

Ruby + Cucumber:如何在代码中执行黄瓜?

我想从Ruby代码中执行Cucumberfunction。 通常,与gem一起安装的cucumber二进制文件在命令行上执行,并指定一个或多个function。 但是,我想定义创建动态function执行流程的逻辑。 换句话说,程序可以确定应该执行哪些function。 是否可以使用Ruby代码中的指定function文件来实例化Cucumber而不是命令行?

capybara – 使用xPath查找离开范围内

我正在尝试使用默认的Rails日期,时间和日期时间字段与Capybara构建日期选择器。 我正在使用within方法来查找字段的选择框,但是当我使用xPath查找正确的框时,它会离开within内并找到元素页面上的第一个匹配项。 这是我正在使用的代码。 我正在测试的页面有2个日期时间字段,但由于此错误,我只能让它更改第一个。 目前我有一个带有id的div容器,它包含了datetime字段,但我确实打算通过标签切换代码来查找。 module Marketron module DateTime def select_date(field, options = {}) date_parse = Date.parse(options[:with]) year = date_parse.year.to_s month = date_parse.strftime(‘%B’) day = date_parse.day.to_s within(“div##{field}”) do find(:xpath, “//select[contains(@id, \”_#{FIELDS[:year]}\”)]”).select(year) find(:xpath, “//select[contains(@id, \”_#{FIELDS[:month]}\”)]”).select(month) find(:xpath, “//select[contains(@id, \”_#{FIELDS[:day]}\”)]”).select(day) end end def select_time(field, options = {}) require “time” time_parse = Time.parse(options[:with]) hour = time_parse.hour.to_s.rjust(2, ‘0’) minute = […]