黄瓜测试用于检查具有特定类的元素的父元素
我有一个 id 为:#post
的元素,并且该元素具有父级
。现在我想检查
.current
。 步骤可能是这样的:Then the element "post" with parent "li" should have class "current"
如果有人可以帮助我定义step_definitions,那就是gr8!
I have an element with id: #post
and that element has parent <li>
. Now I want to check whether the <li>
has class .current
or not.
The step might be like
Then the element "post" with parent "li" should have class "current"
If any body could help me with step_definitions, that'll be gr8!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我用过这个(有效):
I used this, (which works):
使用 webrat,您可以搜索 css 选择器。也许这可以解决您的问题:
我没有尝试这段代码,但它应该可以满足您的目的。
With webrat you can search for an css selector. Maybe this solves your problem:
I didn't try this code, but it should work for your purpose.
这些建议应该适合您,但您可能还需要考虑将选择器与故事分离,以使您的测试套件更易于维护,并且更能体现业务价值。例如:您可以将步骤更改为以下内容:
如果您使用 泡菜:
These suggestions should work for you, but you might also want to consider decoupling your selectors from your stories to make your test suite easier to maintain, and more expressive of business value. Eg: you might change the step to something like:
This becomes pretty easy to implement if you're using Pickle: