Cypress click element by ID / XPATH / Name?

前端 未结 5 1890
一整个雨季
一整个雨季 2021-02-20 11:40

I want to click on an element by XPATH / ID and not the default cypress locator, is it possible?

In selenium I can use find element by XPATH for example:



        
5条回答
  •  -上瘾入骨i
    2021-02-20 11:57

    In Cypress, it works like this:

    cy.get('button[id="category"]').click()
    

    Notice that I just used button as an example here, you should replace that with the label of your element: div, select, textarea, etc...

提交回复
热议问题