想了解css–关闭Capybara测试中的动画的新动态吗?本文将为您提供详细的信息,此外,我们还将为您介绍关于Capybara/RSpec’has_css’匹配器不工作,但has_css、Capyba
想了解css – 关闭Capybara测试中的动画的新动态吗?本文将为您提供详细的信息,此外,我们还将为您介绍关于Capybara / RSpec’has_css’匹配器不工作,但has_css、Capybara 2.0 Beta 发布,Rack 应用测试、Capybara 2.14.1 发布,Web 应用验收测试框架、Capybara 在 Ruby 中使用 RSpec 进行测试的新知识。
本文目录一览:- css – 关闭Capybara测试中的动画
- Capybara / RSpec’has_css’匹配器不工作,但has_css
- Capybara 2.0 Beta 发布,Rack 应用测试
- Capybara 2.14.1 发布,Web 应用验收测试框架
- Capybara 在 Ruby 中使用 RSpec 进行测试
css – 关闭Capybara测试中的动画
我为所有基于jQuery的动画找到了这个解决方案:
<%= javascript_tag’$.fx.off = true;’如果Rails.env.test? %GT;
但是,我使用twitter bootstrap,来自bootstrap的大多数动画都是由CSS 3(使用javascript后备)制作的.所以我的问题是,有没有办法在测试中转换CSS 3过渡和动画?
解决方法
.reset-transition { -webkit-transition: none; -moz-transition: none; -ms-transition: none; -o-transition: none; transition: none; }
您也可以将它应用于ALL并在Bootstrap之后放置此CSS
* { -webkit-transition: none; -moz-transition: none; -ms-transition: none; -o-transition: none; transition: none; }
你可以使它更具体
div,a,span,footer,header { -webkit-transition: none; -moz-transition: none; -ms-transition: none; -o-transition: none; transition: none; }
Capybara / RSpec’has_css’匹配器不工作,但has_css
require 'spec_helper' feature 'View the homepage' do scenario 'user sees relevant page title' do visit root_path expect(page).to have_css('title',text: "Todo") end end
失败的消息是:
1) View the homepage user sees relevant page title Failure/Error: expect(page).to have_css('title',text: "Todo") Capybara::ExpectationNotMet: expected to find css "title" with text "Todo" but there were no matches. Also found "",which matched the selector but not all filters.
标题元素和正确的文本在渲染页面上
但是当我在功能规格中更改这一行时:
expect(page).to have_css('title',text: "Todo")
到这个:
page.has_css?('title',text: "Todo")
然后测试通过. [编辑 – 但是从@JustinKo看到这个测试不是一个很好的测试,因为它总是会通过]
如何获得has_css(…)表单的工作?是配置问题吗?
这是我的Gemfile的相关部分:
group :development,:test do gem 'rspec-rails' gem 'capybara' end
而我的spec / spec_helper.rb设置如下:
ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment",__FILE__) require 'rspec/rails' require 'rspec/autorun' require 'capybara/rails' require 'capybara/rspec' Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } RSpec.configure do |config| # out of the Box rspec config code ommitted config.include Capybara::DSL end
任何人知道我可能做错了什么?
解决方法
您可以通过以下方式强制Capybara考虑不可见元素:visible =>假选项.
expect(page).to have_css('title',:text => 'Todo',:visible => false)
但是,使用has_title方法会更容易:
expect(page).to have_title('Todo')
Capybara 2.0 Beta 发布,Rack 应用测试
Capybara 2.0 Beta 发布了,这是一个很重要的升级版本。
坏消息:如果你升级到 Capybara 2.0 ,你必须对你之前做的测试套件做一些更改。
好消息:一旦你兼容 Capybara 2.0 ,你可在 1.1.2 和 2.0 间进行跨界,无需做任何修改。
兼容性问题:第三方的驱动如 WebKit 或 Poltergeist 还不兼容 Capybara 2.0。同时使用默认的 :selenium 驱动的。
同时, Capybara 2.0 将不兼容 Ruby 1.8.7.
详细的升级指南请看:http://techblog.fundinggates.com/blog/2012/08/capybara-2-0-upgrade-guide/
Capybara 旨在简化测试 Rack 应用(Rails、Sinatra、Merb等应用)的集成过程。Capybara 可模拟一个真实的用户跟Web应用进行交互。
Capybara 2.14.1 发布,Web 应用验收测试框架
Capybara 2.14.1 已发布,Capybara 是一个 Web 应用验收测试框架,通过模拟真实用户交互的方式来测试你的 web 应用。它内置 Rack::Test 和 Selenium 支持,也支持其他驱动。WebKit 通过外部 gem 的形式支持。
更新内容:
Catch correct error when unexpected system modals are discovered in latest selenium
Update default
puma
server registration to encourage it to run in single modeSuppress invalid element errors raised while lazily evaluating the results of
all
Added missing
with_selected
option to the :select selector to matchoptions
/with_options
options - Issue #1865Workaround broken system modals when using selenium with headless Chrome
下载地址:
Source code (zip)
Source code (tar.gz)
>>>【评论有礼】6月6日-30日评论每日更新的“新闻资讯和软件更新资讯”,评论点赞数超过 20 的可登上每周更新的“源资讯”和“软件周刊”两大栏目,点赞数超过 50 的还将获得 5 活跃积分奖励和开源中国定制好礼。详情
Capybara 在 Ruby 中使用 RSpec 进行测试
如何解决Capybara 在 Ruby 中使用 RSpec 进行测试?
在我的索引页上,我有这个 div:
<div>
<h1>galaxy Far,Far Away? Quick Trip to Mars?<br>
Pianeta has you covered.</h1>
<div>
在我的测试文件中,这有效:
RSpec.describe ''home features'' do
it ''displays the name of the app and links to the index-all planets page'' do
visit root_path
expect(page).to have_content(''Space is full of surprises.'')
click_link(''Go Beyond'')
expect(current_path).to eq(''/planets'')
expect(page).to have_content(''galaxy Far,Far Away?'')
end
end
但我希望它与包含的 h1 一起使用。 我这样做了:
expect(page).to have_content(''<h1>galaxy Far,Far Away? Quick Trip to Mars?<br>
Pianeta has you covered.</h1>'')
end
但是测试失败了。我做错了什么?
解决方法
#has_content?
/#has_text?
方法只检查页面的文本内容。它不查看 HTML 标签。
如果您想检查特定 HTML 元素中的内容,可以使用 #within 方法,该方法接受一个块,并将 Capybara 查找的范围限定在匹配的元素内。 #within
引用的元素必须存在,否则 Capybara 将引发异常。
page.within(''h1.glow-header'') do
expect(page).to have_content(''Galaxy Far,Far Away?'')
end
,
如果您不想使用 within
处理单一期望的作用域,您可以这样做
expect(page).to have_css(''h1.glow-header'',text: ''Galaxy Far,Far Away?'')
如果您已经获得了对标题的引用,您还可以执行类似的操作
header = find(''h1.glow-header'')
...
expect(header).to have_text(''Galaxy Far,Far Away?'')
此外,您不应该执行 expect(current_path).to eq(''/planets'')
。一旦您转向使用异步(支持 JS)驱动程序,将 RSpecs eq
匹配器与 Capybara 一起使用将导致不稳定的测试,因为它会阻止 Capybaras 自动等待/重试行为。相反,您应该使用 Capybara 提供的匹配器
expect(page).to have_current_path(''/planets'')
关于css – 关闭Capybara测试中的动画的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于Capybara / RSpec’has_css’匹配器不工作,但has_css、Capybara 2.0 Beta 发布,Rack 应用测试、Capybara 2.14.1 发布,Web 应用验收测试框架、Capybara 在 Ruby 中使用 RSpec 进行测试等相关内容,可以在本站寻找。
本文标签: