当标签环绕输入时,我发现自己无法尝试从标签访问输入。这看起来像是一个容易解决的问题,但我有一点时间。
<label htmlFor="termsAgreement">
<input type="checkbox" name="termsAgreement"/>
<p>Here are the terms of use</p>
</label>
我以为以下可行,但没有运气:
getByLabelText('Here are the terms of use', {selector: 'input'});
可以在此处找到带有几个测试的小示例代码段:
看起来我正在使用name
字段而不是预期的id
字段来定位相关的输入。