Cypress click element by ID / XPATH / Name?

前端 未结 5 1781
一整个雨季
一整个雨季 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条回答
  •  迷失自我
    2021-02-20 11:53

    The first question contains two different selectors, the first (selenium) look for an id category and the second for a class category.

    In fact :

    d.findElement(By.id("category")).click();
    ==
    cy.get('#category').click()
    

    So yes you could select an element by it's ID !

    If (and i don't think) you want to have others possibility for selecting your elments look for jquery selector (jquery is exposed in cypress)

提交回复
热议问题