小编she*_*nia的帖子

React 测试库 getByLabelText 不连接多部分 aria-labelledby

沿着这篇 MDN 文章的思路,我有一个由三个不同元素的组合标记的复选框输入:一个标签、一个文本字段,然后是另一个标签。

因此,复选框输入有一个aria-labelledby属性,其值类似于label1 text-field label2

<input type="checkbox" aria-labelledby="allow-up-to num words-in-between" />
<div>
  <label id="allow-up-to">allow up to</label>
  <input id="num" type="text" value="0" />
  <label id="words-in-between">words in between</label>
</div>
Run Code Online (Sandbox Code Playgroud)

在我的测试中,我尝试根据该标签获取复选框。

getByLabelText('text of label1')我可以使用或成功获取输入getByLabelText('text of label2'),但为其提供完整的串联标签getByLabelText('text of label1 value of text-field text of label2')会导致找不到任何内容。

getByLabelText("allow up to"); // works
getByLabelText("words in between") // works
getByLabelText("allow up to 0 words in between") // does not work
Run Code Online (Sandbox Code Playgroud)

尝试getByLabelText('value of text-field')也不起作用,但即使我从 中删除文本字段aria-labelledby,我仍然无法使用 …

react-testing-library

5
推荐指数
1
解决办法
8045
查看次数

XQuery: look for node with descendants in a certain order

I have an XML file that represents the syntax trees of all the sentences in a book:

<book>
    <sentence>
        <w class="pronoun" role="subject">
            I
        </w>
        <wg type="verb phrase">
            <w class="verb" role="verb">
                like
            </w>
            <wg type="noun phrase" role="object">
                <w class="adj">
                    green
                </w>
                <w class="noun">
                    eggs
                </w>
            </wg>
        </wg>
    </sentence>
    <sentence>
        ...
    </sentence>
    ...
</book>
Run Code Online (Sandbox Code Playgroud)

This example is fake, but the point is that the actual words (the <w> elements) are nested in unpredictable ways based on syntactic relationships.

What I'm trying to …

xpath xquery basex

4
推荐指数
1
解决办法
89
查看次数

标签 统计

basex ×1

react-testing-library ×1

xpath ×1

xquery ×1