我只想 select 带有柏树的网站中带有文本 "Continue" 的按钮

I just want to select the button with the text "Continue" within a website with cypress

当我用普通方法搜索按钮时 returns 2 个结果

cy.get('[data-testid="cc-button__element"] > [data-testid="cc-button__text"]')

然而,当我使用 cypress 自己的工具进行搜索时,它确实很快找到了它并且 returns 1 个结果。

cy.get('.block > [data-testid="cc-button"] > [data-testid="cc-button__element"]')

我知道这是有效的,但是,我想用传统的方法来做,这样以后如果有变化也不会影响我的按钮搜索方法。

如果文本继续在您的网页中只出现一次,您可以使用 contains 找到它并单击它。

cy.contains('Continue').click()