Unable to access input component using react testing library

65 views Asked by At

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

0

There are 0 answers