0

I'm trying to find an element, its id will always change, as it is a register.

Exexample: https://i.stack.imgur.com/Bql94.png

I would like to click on 'Edit' but the id of this class will always be different. How do I map and click on 'Edit' using Capybara or SitePrism?

1 Answers1

0

You don't have to have an id to click on an element, all you need is a selector that will find a unique element and/or the ability to scope the selector to make it refer to a unique element. In the example case with Capybara you could do

click_link(class: 'professional-edit')

if you needed to scope it to the row for a specific user you could use a CSS attribute selector like

within('[name="Automacao Usuario"]') do
  click_link(class: 'professional-edit')
end

or just using a single CSS find and click

find('[name="Automacao Usuario"] a.professional-edit').click

Note: in the future please add HTML as text to your question - adding pictures of HTML makes it much harder for people to interact with and answer your questions

Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78