我有一个文件字段,它有opacity: 0
一个假的按钮.它是一种常见的css技术,用于伪造一种在不同浏览器中一致显示的"上传按钮".
Capybara不允许我打电话attach_file
给那个输入.错误是Selenium::WebDriver::Error::ElementNotVisibleError: Element is not currently visible and so may not be interacted with
.
有谁知道强迫水豚与隐形元素互动的方法吗?
答案仍然没有答案,但我找到了解决方法.没有什么是智能的,只需用简单的脚本使元素可见即可
page.execute_script %Q{
$('#photos').css({opacity: 1, transform: 'none'});
}
Run Code Online (Sandbox Code Playgroud)
我发布它作为记录.
我的问题似乎很常见,但我没有在文档或互联网本身找到任何答案.
它似乎是这个问题的一个克隆has_many,同时尊重factory_girl中的构建策略,但在post-factory_girl改变了很多之后的2.5年.
我有一个名为照片的has_many关系的模型.我想填充这个有很多关系,保留了我对构建策略的选择.
如果我打电话,offering = FactoryGirl.build_stubbed :offering, :stay
我希望offering.photos
成为一个存根模型的集合.
我发现实现这一目标的唯一方法是:
factory :offering do
association :partner, factory: :named_partner
association :destination, factory: :geolocated_destination
trait :stay do
title "Hotel Gran Vía"
description "Great hotel in a great zone with great views"
offering_type 'stay'
price 65
rooms 70
stars 4
event_spaces 3
photos do
case @build_strategy
when FactoryGirl::Strategy::Create then [FactoryGirl.create(:hotel_photo)]
when FactoryGirl::Strategy::Build then [FactoryGirl.build(:hotel_photo)]
when FactoryGirl::Strategy::Stub then [FactoryGirl.build_stubbed(:hotel_photo)]
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
没必要说IT必须存在更好的方法.
想法?