我有一个html代码
<div class="form-card">
<h2 class="fs-title" test-data="area_1">
About DigCompEdu
</h2>
<p></p>
<label for="academic_teaching" class="question" test-data="question_1">
<b>1- </b>
</label>
<small id="academic_teachingHelp" class="form-text text-muted">
</small>
<div class="form-check question-form-check ">
<div class="row">
<div class="col-1">
<input class="radio" type="radio" value="0" id="3" name="2" test-data="answer_1" />
</div>
</div>所以,我有一个带有testdata名称的h1,然后我有了一个表单,这个表单包含有多个检查收音机的问题。我想访问这个检查,而不是通过调用(test-data="answer_2"),因为我有另外一个提示,并且不想检查它们,
我确实是这样的,但这不管用:
cy.get('[test-data="area_1"]~[test-data="answer_2"]').check({force: true})有人有别的主意吗?
发布于 2022-04-27 09:46:55
这可能是选择器之间的~,我以前从未见过。
它能用一个空格来代替吗?
cy.get('[test-data="area_1"] [test-data="answer_2"]').check({force: true})如果标题后面跟着如下形式
<h2 class="fs-title" test-data="area_1">
About DigCompEdu
</h2>
<div class="form-check question-form-check ">
...然后你就会像这样查询
cy.get('[test-data="area_1"]')
.next('.form-check') // next element on page
.find('[test-data="answer_2"]') // this looks inside '.form-check'
.check({force: true})https://stackoverflow.com/questions/72026387
复制相似问题