0

I have the following problem: I want to map these elements but there are repeated correspondences. I don't want to use xpath!. IF I map using input name or class there will be repeated matches

class CriaScreenCadastro < SitePrism::Page
   set_url 'https://quasar-flash-staging.herokuapp.com/#boxCadastro'
    
#input fields
element :cnpj,             :xpath,              '//*[@id="boxCadastro"]/div/div[2]/div[1]/div/input'
element :cpf,              :xpath,              '//*[@id="boxCadastro"]/div/div[2]/div[2]/div/input'

<input name="cnpj" class="sc-fzpisO jHQZJv" value="">
<input name="cpf" class="sc-fzpisO jHQZJv" value="">
end
sabnola
  • 5
  • 3
  • The question is not entirely clear to me, but if you don't want to use a XPath selector [you could use a CSS selector instead](https://github.com/site-prism/site_prism#css-selectors-vs-xpath-expressions). For a collection of elements instead of a single collection [use `elements` instead of `element`](https://github.com/site-prism/site_prism#element-collections). – 3limin4t0r Mar 11 '21 at 17:35
  • Is it possible for you to give me an example using my problem? – sabnola Mar 11 '21 at 17:57
  • I can't because the problem is not clear. The only thing I got from the question is "I don't want to use XPath" and something about "repeated matches". In your problem *"I want to map these elements but there are repeated correspondences."* I assume, "these" refers to the two elements below, but I don't know what "repeated correspondences" refers to. The sentence *"IF I map using input name or class there will be repeated matches"* is also strange, since both input elements have a unique name. So how does using the input name produce repeated matches? – 3limin4t0r Mar 11 '21 at 21:20
  • I navigated through the link you gave me and got !! .. Thank you – sabnola Mar 11 '21 at 21:25

0 Answers0