Tag: 水豚

如何用capybara和selenium填充tinymce-rails编辑器?

我使用水豚测试tinymceforms有困难。 我正在使用tinymce-rails并且在我的表单中有7个编辑器。 我也使用asciimath插件与tinymce。 一切正常,但我无法编写测试来填写tinymce编辑器。 以下是我的步骤定义代码的外观,与此处描述的内容非常相似: within_frame(“content_ifr”) do editor = page.find_by_id(‘tinymce’) editor.native.send_keys ‘test’ end 问题是当我运行以下内容时: editor.native.clear # works, clear the editor area, I’m testing this with pry editor.native.send_keys :tab # works, moves focus to next input editor.native.send_keys ‘test’ # returns “”, nothing happens, nothing in editor 如此clear , send_keys :tab按预期工作。 但我不能发送任何字符串。 send_keys函数总是返回空字符串,当我使用send_keys进行测试时没有任何反应。 这里出了什么问题? 以及如何调试/调查问题? 谢谢。

Poltergeist Stripe checkout.js

我正在尝试在我的Rails应用程序中测试Stripe checkout弹出窗口( http://www.stripe.com/checkout )。 我正在使用Capybara + selenium-driver,一切运转良好。 加载页面后,checkout.js会添加一个iframe,我可以访问它 within_frame(‘stripe_checkout_app’) do do something end 现在,切换到Poltergeist,我收到此错误: 失败/错误:within_frame(’stripe_checkout_app’)执行Capybara :: Poltergeist :: FrameNotFound:找不到框架’stripe_checkout_app’。 如果我检查页面,就没有iframe。 所以我认为这个脚本 我用Poltergeist运行测试时没有加载。 更新 我尝试用Capybara-webkit运行测试,结果相同。 Failure/Error: Capybara.within_frame(‘stripe_checkout_app’) do Capybara::Webkit::InvalidResponseError: Unable to locate frame. 我也试着等了半分钟! 同 sleep 30 这些是我的webmock设置: RSpec.configure { |config| WebMock.disable_net_connect!(allow_localhost: true) } 更新2: ‘stripe_checkout_app’是iframe的名称。

Rails + Cucumber / Capybara:如何在测试中设置/检索cookie?

我正在实现一个懒惰的登录function。 我的黄瓜function应该描述它: Feature: User log in Scenario: Lazy login Given I didn’t log out the last time I was on the site When I go to the homepage Then I should automatically be logged in 这些是我的步骤定义: Given(/^I didn’t log out the last time I was on the site$/) do user = FactoryGirl.create(:user) visit new_user_session_path fill_in(‘user[email]’, […]

使用Cucumber和Capybara进行分类测试

有没有办法用Cucumber和Capybara测试列表的排序。 使用javascript在客户端完成排序。 我在思考以下几点: Then I should see “first element” and then I should see “second element” 不幸的是,我不知道如何构建这些步骤。 谢谢您的帮助!

save_and_open_page不能与capybara 2.0一起使用?

我刚刚将我的水豚更新到2.0,并且我的所有save_and_open_page调用都返回了一个没有样式的html页面。 它在页面顶部正确显示样式表链接。 当我回到capybara 1.3时,样式再次起作用。 任何人都知道如何解决这个问题,和/或问题是什么? 谢谢,戴夫 更新1。 破解: 我找到了一个合理的方法来解决simonmorley推荐的链接问题 :Capybara Webkit问题 ,它指向: capybara-screenshot 它涉及使用capybara-screenshot gem来获取页面的截图。 将它与生成html的save_and_open_page结合使用时,您可以看到它的外观,并查看HTML。 save_and_open_page Capybara::Screenshot.screenshot_and_open_image 如果我可以让Capybara::Screenshot.screenshot_and_save_page工作,那么我认为我可能有一个解决方案(如果名称暗示我认为它的行为)。 但是,当我尝试它时,我得到cannot load such file — capybara/util/save_and_open_page 更新2。 ! 等一下,screenshot_and_open_image现在不能正常工作(没有创建或显示png图像)。 ! 更新3。 测试应用: 我创建了一个测试应用程序,并将其发布在Github上的test_capybara_screenshot中 。 当我在开发中运行这个测试应用程序时,页面会显示出醒目的红色背景样式。 当我运行测试时,唯一对我有用的是save_and_open_page,除了没有样式。 注意,当我运行任何测试时,我收到以下警告: 警告:Nokogiri是针对LibXML版本2.7.8构建的,但动态加载了2.7.3 rspec测试的详细信息: save_and_open_page会出现一个无聊的白色背景(没有样式)。 screenshot_and_open_image返回错误: Rack :: Test水豚驱动程序无法输出屏幕截图。 跳绳。 打开失败////ocuments/experiments/test_capybara_screenshot/tmp/capybara/screenshot-2012-11-26-07-48-29.png with options {}:找不到应用程序来处理’/〜/ Documents / experiments / test_capybara_screenshot /tmp/capybara/screenshot-2012-11-26-07-48-29.png” screenshot_and_save_page返回: […]

Cucumber / Capybara测试不再在Rails 3项目中运行

这些gem的最新版本不再相互配合吗? 似乎某些东西可能已经从我的捆绑中解决了。 undefined local variable or method `node’ for # (NameError) ./features/step_definitions/web_steps.rb:35 ./features/step_definitions/web_steps.rb:14:in `with_scope’ ./features/step_definitions/web_steps.rb:34:in `/^(?:|I )follow “([^”]*)”(?: within “([^”]*)”)?$/’ features/signing_in.feature:11:in `And I follow “Login”‘ 我所要做的就是运行一个function: bundle exec cucumber features/signing_in.feature 我无法进行任何测试。 capybara-0.4.0 cucumber-rails-0.3.2 cucumber-0.9.2 我重新运行了黄瓜的安装脚本。 我还要补充一点,我不知道在Capybara :: Drive :: RackTest中试图称之为“Node”的是什么。

Capybara匹配器存在按钮或链接

网页上的用户不区分“按钮”和“链接样式为按钮”。 有没有办法添加检查页面上是否有“按钮或链接”? 比如Capybara有步骤: page.should have_button(‘Click me’) 找不到按钮设置的链接。

Capybara,在css元素中找到

我正在使用Ruby on Rails 3,Cucumber和Capybara 我已经搜索了相当长的一段时间,我无法弄清楚如何在css标签中找到特定的页面元素。 在我的例子中,我需要确保在表格中找到名称,而不是在“欢迎[名称]”中。 我试过类似的东西: within(‘table’) do page.body.index(“[Name]”) end 我有一个id=’table’ 。 但我想知道如何为任何css元素执行此操作,例如: within(‘h2’) do page.body.should have_content (‘stuff’) end 我认为我的问题与page.body有关,但我不确定如何将其包含在特定的css标签中。 提前致谢!

水豚没有找到表格元素

这是我第一次尝试Capybara,我似乎无法找到为什么它找不到我的表格元素。 每次我试图找到一个表单元素, When /^they submit a resolution in Markdown$/ do visit “/resolutions/new” fill_in “title”, :with => “Title” fill_in “libelle”, :with => “Some text here\n\nNew paragraph” click_button “Submit” end 它不知道它在哪里, Scenario: Submission of a resolution # features/resolutions.feature:5 Given the user is a member # features/step_definitions/user_steps.rb:26 When they submit a resolution in Markdown # features/step_definitions/resolution_steps.rb:8 cannot fill […]

无法理解水豚的行为

我对我的Rails应用程序进行了这种集成测试: require ‘test_helper’ class StudyCapybaraTest :chrome) end Capybara.current_driver = :selenium_chrome #Capybara.default_wait_time = 5 visit login_path fill_in “session_email”, with: @user.email fill_in “session_password”, with: ‘password’ click_button “session_commit” end test “full study process” do assert_title “Home | Word Up” visit study_user_path(@user) …. end end 奇怪的是,当我删除第一个测试的第一行“完整的学习过程” assert_title “Home | Word Up” 测试失败,因为测试用户似乎没有登录。移动时会出现同样的问题 visit study_user_path(@user) 进入设置function(就像之前一样)。 但这并没有改变序列和逻辑,对吧? 我唯一能想到的是,断言来得很早,应用程序没有时间执行满足断言所需的指令。 这是一个时间问题,如果是这样,我怎样才能防止它们在将来发生? 谢谢!