黄瓜中的 click_link 图像

发布于 2024-09-27 01:34:37 字数 189 浏览 0 评论 0原文

<a href="/videos/21-running">
  <img height="120" src="/images/sample-image.jpg" alt="Running">
</a>

请支持我通过 alt 或 src 单击 cucumber 中的链接。谢谢。

<a href="/videos/21-running">
  <img height="120" src="/images/sample-image.jpg" alt="Running">
</a>

Please support me a way click link in cucumber by alt or src. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

各自安好 2024-10-04 01:34:37

假设您使用 capybara 来支持您的黄瓜规格,类似以下步骤的操作应该可以解决问题。

When /^I follow image link "([^"]*)"$/ do |img_alt|
    find(:xpath, "//img[@alt = '#{img_alt}']/parent::a").click()
end

在规范中,您现在可以说

When I follow image link "Running"

总体思路是您需要某种自定义步骤来处理此问题。

Assuming you are using capybara to back your cucumber specs something like the following step should do the trick.

When /^I follow image link "([^"]*)"$/ do |img_alt|
    find(:xpath, "//img[@alt = '#{img_alt}']/parent::a").click()
end

In the spec you can now just say

When I follow image link "Running"

The general idea is that you need some kind of custom step to handle this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文