Besides the ability to click on button elements, for example @Jim Mitchener, you can also click on a part of the text as follows:
# WhenI click on the text "Sign in" When(/^I click on text "(.*?)"$/) do |text| click_text(text) end def click_text(text) elem = find(:xpath, "//*[contains(translate(text(), '#{text.upcase}', '#{text.downcase}'), '#{text.downcase}')]", match: :first, wait: false) scroll_to(elem, -200) elem.click end
This helper function performs the same function as find(selector).click , it finds a text element.
I found this article very well, it explains the various types of steps that you can write in cucumbers.
Nesha Zoric Mar 16 '18 at 15:36 2018-03-16 15:36
source share