cypresschaimochawesome

How to select 2nd row of table and enter data in column if 2nd row is contains data, then it selects column of 3rd row using cypress devextreme table


Want to enter data: Table Image and source code

My Code: My cypress code

I want to select 2nd row of table and enter data in column because 1st row is disable and if 2nd row contains then it auto clicks on 3rd row. My code selects 1st row every time


Solution

  • Your code is selecting the first, uneditable row every time because it contains the same class as your row to select. If cy.get() returns multiple elements, then the first one is yielded to the subsequent commands if a specific element is not specified. So, we can get around this by specifying .eq().

    cy.get('#TWGanttArea')
      .find('.taskEditRow') // use find, because get always starts from root
      .eq(1) // yields the returned element at the index-0'd 1 position
      .find('td.taskTitle') // finds child elements of type td with class taskTitle
      .type('foo');