How to get an element that has a dynamic selector in Cypress

  cypress, javascript

My script has a button which leads to an external site where I need to input some information in a field.

I’m not able to find a way to select that field because it’s within an iframe and also has a dynamically generated ID. That ID has 2 characters at the end that are always consistent.

So far I’ve tried:

cy.get('#*_2'); –> Trying to use a wildcard to click on the element that has a _2 at the end but it does not work

I’ve tried using a cy.get('input[data-collect-as="input"]') –> It’s not able to find this element either.

Any help would be appreciated.

enter image description here

Source: Ask Javascript Questions

LEAVE A COMMENT