Search code examples
frontendcypresse2e-testing

Find an element in cypress to click that can't be found


I have been trying for hours to get an element and click on it but cypress is not being very nice. Here is the front end code

enter image description here

I have tried all of these

cy.get('#Area\ Data').click()
cy.get('#Area\ Data path').click()
cy.get('#Area\ Data > .circle_icon__1sTPA > svg').click()
cy.get('#Area\ Data > .circle_icon__1sTPA').click()
cy.get('.circle_left_9KD8d > .circle_container__2H4VS > #Area\ Data > .circle_icon__1sTPA > svg').click()

any idea why none of these are working?


Solution

  • You can use:

    cy.get('[id="Area Data"]').click()
    

    OR

    cy.get('[data-id="Area Data"]').click()
    

    In case the click is not happening you can add {force: true}. Forcing a click overrides the actionable checks Cypress applies and will automatically fire the events.

    cy.get('[id="Area Data"]').click({force: true})