通过 xpath 选择器与元素交互
我看到很多文档和人们使用 xpath 与水豚的示例,但由于某种原因,我没有找到任何关于如何做最简单的事情的信息...单击由 xpath 选择器标识的(按钮|链接|任何内容)。如何完成如下步骤定义:
Given /^I click the element identified by xpath "([^"]*)"$/ do |xpath_selector|
click_button(xpath_selector)
end
I see a lot of documentation and examples of people using xpath with capybara but for some reason I don't find anything on how to do the simplest thing... click a (button|link|whatever) identified by an xpath selector. How does one accomplish a step definition like:
Given /^I click the element identified by xpath "([^"]*)"$/ do |xpath_selector|
click_button(xpath_selector)
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想手动指定 xpath 选择器并单击该元素,无论它是什么(按钮、链接、div 等),请尝试:
If you want to manually specify the xpath selector and click the element no matter what it is (button, link, div, etc), try: