0

I am trying to type text in the textbox using selectors. However the textbox shares the same ID. How can i index selectors. I was able to do it via xpath. However i need to pass it as selector

textbox id = #input1

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
FlowStack
  • 82
  • 1
  • 10
  • 1
    What you've done so far? – frianH Apr 06 '20 at 03:17
  • This is how I am passing value to the 1st text box const id_2 = 'input’; const val1 = '123'; const inField = new dataPill(testcafe, `#${id_2}`); await inField.typeText(val1); I need to pass value to the second text box which has same ID i.e #input. So I wanted to know how I can index it for second text box Thanks – FlowStack Apr 06 '20 at 06:32

1 Answers1

1

Element IDs should be unique within the entire document. I recommend that you avoid using the same ID for several elements.

You might want to enumerate elements by their type (input). Refer to the Enumerate Elements Identified by a Selector topic where this example is illustrated in action.

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47