1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Cypress use regex to retrieve elements with matching text in id

Discussão em 'Angular' iniciado por methuselah, Junho 13, 2025.

  1. methuselah

    methuselah Guest

    I have multiple div elements with the id features-##### and features-#####, where the # is a dynamic figure.

    How would I get Cypress to find all elements with the matching part of the id features-, and then click on the first or second in a programmatic manner?

    This is that I have done so far, but I can't figure out hwo to use regex to retrieve all the elements I did then process them programmatically.

    describe('builder features component', () => {
    it('should allow the user to select a features component', () => {
    cy.get(el).should('div.id', /^features-\w+/).first().click();
    });
    });

    Continue reading...

Compartilhe esta Página