我有一個包含包含的 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,之后我有一個表格,這個表格包含帶有 multin check radio 的問題.. 我想訪問這個檢查,而不是僅僅通過呼叫 ([test-data="answer_2"]) 因為我有另一個提示,不想像這個一樣檢查它們,
我這樣做了,但它不起作用:
cy.get('[test-data="area_1"]~[test-data="answer_2"]').check({force: true})
有人有另一種想法嗎?
uj5u.com熱心網友回復:
它可能是~選擇器之間的,我以前沒見過。
它是否與之間的空格一起使用?
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://www.uj5u.com/houduan/465849.html
下一篇:無法訪問地圖
