如何找到由 Dragonfly with Cucumber/Capybara 生成的图像?
在对 如何在带有 Cucumber/Capybara 的页面上查找图像,有人问:
我似乎不知道如何得到这个 使用生成的 URL 蜻蜓。它们看起来像这样: /media/BAh_some_long_string_AwIw/12_11_52_810_5x5.jpg?s=7e360000,其中 5x5.jpg 是我的文件名。我已经 尝试过类似的东西: //img[@src="/media//#{image}?s=*"] 但它不起作用。有什么建议吗? – Ramon Tayag 2 月 25 日 4:18
我遇到了类似的问题,甚至更糟 - 就我而言,生成的图像路径甚至不包含(jpg | png | gif)文件名,它们只有这些非常长的ID:(
<img src="/media/BAhbB1sHOgZmSSIdNGQ4MTEyOGU3ZjViZmQwZTQ4MDAwMDAyBjoGRVRbCDoGcDoKdGh1bWJJIg0yMDB4MjAwIwY7BlQ" />
使用蜻蜓与mongo / gridfs)
这些路径渲染得很好,但我不知道如何找到他们在黄瓜/水豚步骤中:P
有什么想法吗?我查看了 Dragonfly 的功能,但它们只测试图像的渲染本身,而不检测它是否存在于 html 页面中。
In the comments to the solution for How do I find an image on a page with Cucumber/Capybara, somebody asked:
I can't seem to figure how to get this
to work with URLs generated by
Dragonfly. They look like this:
/media/BAh_some_long_string_AwIw/12_11_52_810_5x5.jpg?s=7e360000, where 5x5.jpg is my file name. I've
tried something like:
//img[@src="/media//#{image}?s=*"]
but it doesn't work. Got any tips? – Ramon Tayag Feb 25 at 4:18
I have a similar problem, only worse - in my case, the generated image paths don't even include a (jpg|png|gif) file name, they only have these really long ids:
<img src="/media/BAhbB1sHOgZmSSIdNGQ4MTEyOGU3ZjViZmQwZTQ4MDAwMDAyBjoGRVRbCDoGcDoKdGh1bWJJIg0yMDB4MjAwIwY7BlQ" />
(Using dragonfly with mongo/gridfs)
These paths get rendered alright, but I can't figure out how to find them in a Cucumber/Capybara step :P
Any ideas? I looked at the Dragonfly's features, but they only test the rendering of the image itself, without detecting it's existence within an html page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在与 Dragonfly 的作者交谈之后回答我自己的问题(他正在努力使这变得更容易):
关键是将 [attachment]_name 字段添加到模型中,Dragonfly 会自动填充该字段,然后将其作为后缀传递给 url()。除了生成的蜻蜓标识符之外,路由还需要允许 :file_name 参数。
Answering my own question, after talking to Dragonfly's author (he's working on making this easier):
The key is adding an [attachment]_name field to the model, which Dragonfly populates automatically, and then passing it on as a suffix to url(). And the routes needs to allow for a :file_name param besides the generated dragonfly identifier.