使用 Capybara w/ Selenium,我将如何单击表格行?
只是想知道是否有可以与任何元素一起使用的 click_link / click_button 的替代方案,因为我的一些可点击元素不是标准的 html 可点击元素(例如 tr 元素),但它们仍然包含 href 属性。
启用 JavaScript。
Would simply like to know if there's an alternative to click_link / click_button that can be used with any element as some of my clickable elements are not standard html clickables such as tr elements, but they still contain href attributes.
Javascript enabled.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我在 html 月视图中遇到了同样的情况,我必须选择一个月中的某一天。我尽可能保持简单,这只是做到这一点的一种方法。
I had the same situation with a html month view, I had to choose a day of month. I kept it as simple as I could and this is only one way of doing this.
你用黄瓜吗?不确定这对您是否有任何用处,但这里有一个黄瓜步骤定义,用于单击带有硒的任何内容:
Are you using cucumber? Not sure if it's any use to you, but here's a cucumber step definition for clicking anything with selenium:
我过去曾尝试过 javascript 解决方案,它的工作原理是按钮确实被单击,但黄瓜无法将其识别为已完成的步骤。
I have tried the javascript solution in past, it works in the sense that the button do gets clicked, but cucumber fails to recognise it as a completed step.
然后使用 JavaScript:
Use Javascript then: