Can you help me with a more flexible code for this method?
static getTemplateItemName() {
const x = this.templateItem.find('.template-name').contains('Basic elements').scrollIntoView({ensureScrollable: false});
cy.get('.template-cover').within(() =>
cy.get('.btn-link-primary').contains('Preview').click({force: true});
};
I am trying to update the code to make it dynamic and not dependent on .eq(2). Any suggestions on how to achieve this?
Below is the HTML structure:
<div _ngcontent-nbr-c91="" class="template-cover">
<div _ngcontent-nbr-c91="" class="template-description">
<div _ngcontent-nbr-c91="" class="template-name">
<p _ngcontent-nbr-c91="" class="text-xs">Basic elements</p>
</div>
<div _ngcontent-nbr-c91="" class="template-actions ng-star-inserted">
<button _ngcontent-nbr-c91="" class="btn btn-link-primary">Preview</button>
<button _ngcontent-nbr-c91="" class="btn btn-outline-primary"> Select </button>
</div>
<!---->
</div>
</div>
Thank you!