cy,click() is not clicking the entity i want to click instead click some other entity in cypress

Viewed 20

There is a text field in which I enter random data and save the form, now I want to click the edit button on the basis of that value which consists of a random value

how I enter a random value in the text field and save it in a variable.

function Alpha_Numeric() {
        
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

    for (var i = 0; i < 5; i++)
      text += possible.charAt(Math.floor(Math.random() * possible.length));

    return text;
   }

Calling variable

cy.contains('td',text).get('#work_order_edit').click()

Instead of click the specific element the pointer click on random vale in the tablerandom value text in table

pointer clicking

1 Answers

Try moving from the cell to the row, then finding the edit button

cy.contains('td',text)
  .parent('tr')
  .find('#work_order_edit')
  .click()
Related