选择一个材质UI FormControlLabel组件

时间:2020-07-02 19:51:10

标签: reactjs jestjs react-testing-library

我正在使用Material UI库中的组件,即FormControlLabel

每个单选按钮都会产生以下输出:

<label class="MuiFormControlLabel-root">
   <span class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root-63 MuiRadio-root MuiRadio-colorSecondary PrivateSwitchBase-checked-64 Mui-checked MuiIconButton-colorSecondary" aria-disabled="false">
      <span class="MuiIconButton-label">
         <input class="PrivateSwitchBase-input-66" name="myRadio" type="radio" value="Some Value" checked="">
         <div class="PrivateRadioButtonIcon-root-67 PrivateRadioButtonIcon-checked-69">
            <svg class="MuiSvgIcon-root PrivateRadioButtonIcon-layer-68" aria-hidden="true">...</svg>
         </div>
      </span>
   </span>
   <span class="MuiTypography-root MuiFormControlLabel-label MuiTypography-body1">Some value</span>
</label>

我应该如何定位此元素?

我想在测试中选择这些单选按钮之一。

0 个答案:

没有答案