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
2
There are 2 answers
0
On
You can't use cy.get().get()
sequence like that, because the 2nd .get()
starts searching at the <body>
element and ignores the first cy.get()
.
The correct sequence for your test is cy.get().find()
because .find()
does start it's search from the result of the previous cy.get()
.
To locate the empty row, you can use .emptyRow
class in the selector.
cy.get('#TWGanttArea')
.find('tr.emptyRow')
.find('td.taskTitle')
With DevExtreme DataGrid you have to click the cell before you can edit data.
cy.get('#TWGanttArea')
.find('tr.emptyRow')
.find('td.taskTitle')
.click() // edit mode
.type('some data here') // data entry
The DataGrid may modify the DOM after clicking, in which case you may get "detached" error.
If that happens, use an alias to perform the steps.
cy.get('#TWGanttArea')
.find('tr.emptyRow')
.find('td.taskTitle')
.as('editCell')
cy.get('@editCell').click() // edit mode
cy.get('@editCell').type('some data here') // data entry
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()
.