<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.
<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.
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.