最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to find label with some name using cypress? - Stack Overflow

programmeradmin2浏览0评论

I want to check the element next to the label username to be a span with text certificate uploaded

below is the html

<div class="square">
    <label>username</label>
    <span>cerfiticate uploaded</span>
</div>

Could someone help me with this? Thanks

I want to check the element next to the label username to be a span with text certificate uploaded

below is the html

<div class="square">
    <label>username</label>
    <span>cerfiticate uploaded</span>
</div>

Could someone help me with this? Thanks

Share Improve this question edited Nov 15, 2022 at 14:10 Fraction 13k5 gold badges32 silver badges52 bronze badges asked Nov 15, 2022 at 13:22 user19725419user19725419
Add a ment  | 

1 Answer 1

Reset to default 5

You can use cy.contains() like this:

cy.contains('span', 'cerfiticate uploaded');

Or use it with cy.next() If you want to chain the span with label:

cy.contains('label', 'username')
.next()
// or
//.next('span')
.should('have.text', 'cerfiticate uploaded');

For the original question:

You can use cy.get() like this:

cy.get('input[placeholder="something"]')
.should('be.disabled');
发布评论

评论列表(0)

  1. 暂无评论