There's no one answer for this question. It all depends on how specific you need to be and how many other potentially matching elements there are on the page. You also don't state what you want to use rather than XPath, so I'm assuming CSS and the text
filter. Some potential options may be
element :txt_cpf_branco, :css, '#gatsby-focus-wrapper span', text: 'Preencha o CPF correto, por favor. Em caso de paciente menor de idade sem CPF, inclua o da pessoa responsável'
or since the default text matching is substring you could do
element :txt_cpf_branco, :css, '#gatsby-focus-wrapper span', text: 'Preencha o CPF correto'
also since :css
is the default selector type you can generally drop it
element :txt_cpf_branco, '#gatsby-focus-wrapper span', text: 'Preencha o CPF correto'
If you also want to check the part of the class of the element to narrow down you could pass a regexp to the class filter
element :txt_cpf_branco, '#gatsby-focus-wrapper span', text: 'Preencha o CPF correto', class: /signUpFormFields__InputError-/
Using those examples you should be able to do the rest of the elements you're looking to change. As stated in response to one of your previous questions, you should be able to pass anything to element
that you could pass to Capybaras find
method -https://www.rubydoc.info/github/jnicklas/capybara/Capybara/Node/Finders#find-instance_method - which includes all the standard options shown in that documentation and any selector type specific options too (the :css selector type doesn't have any extra options)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…