2

I am trying to check the value of input component, .i.e if the value equals==afghanistans then it will pass the test.

Is there any way to access the this component using the provided name attribute('otherNames[0]')?

  <div>
    <div>
      <div>
        <div>
          <label>Other Names</label>
        </div>
      </div>
      <div>
        <div>
          <div role="input">
            <input name="otherNames[0]" type="text" class="MuiInputBase-input MuiInput-input" value="Afghanestan">
          </div>
        </div>
      </div>
    </div>
  </div>
  <div>
    <div>
      <div>
        <div>
          <div>
            <input name="otherNames[1]" type="text" data-testid="Input-inner" value="">
          </div>
        </div>
      </div>
    </div>
  </div>

So far I have tried this:

screen.getByRole('textbox',{name:"otherNames[0]"})

But it returns undefined

sbolel
  • 3,486
  • 28
  • 45
  • That's for selecting by _accessible_ name, usually the label of a control. Also you should [avoid using abstract roles](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles#6._abstract_roles), particularly on a div element that's _not_ interactable. – jonrsharpe Apr 28 '23 at 13:23

0 Answers0