Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a row and select a specific td in cypress?

Tags:

People also ask

How do I select a table row?

Click the left border of the table row. The following selection arrow appears to indicate that clicking selects the row. You can click the first cell in the table row, and then press CTRL+SHIFT+RIGHT ARROW.

How do you find the value of an element in Cypress?

You can check a value of an input element using the built-in Chai-jQuery assertion "have. value".

How do tables work in Cypress?

A table structure has an html consisting of <table> tag followed by <tr> and finally <td> tag. The rows are represented by <tr> and the column values are represented by <td>. Now to retrieve a value from a cell appearing in the next column of the same row, we have to move to the second column.

How do I get text in Cypress?

Cypress can validate the text on an element with the help of jQuery text() method. This method shall help us to fetch the text content on the selected element. We can also put assertions on the text content of the element. cy.


I have a table with 6 columns and variable rows. Now i want cypress to test the delete button. so i create a testitem in my table in the test before and want my program to delete this testitem.

How can i search in a table in column 2, filter the row and click on the button in column 6 with cypress?

I read the docu and guide on cypress.io but i have not find any solutions.

    <div class="row">
        <div class="top-buffer"></div>
        <div class="panel panel-primary">
            <div class="panel-heading panel-head">Article</div>
            <div class="panel-body">
                <div class="btn-group">
    
                    <a asp-action="Edit" asp-route-id="@Guid.Empty" class="btn btn-primary"><i class="" glyphicon glyphicon-plus"></i>NEW</a>
                </div>
                <div class="top-buffer"></div>
                <table class="table table-bordered table-striped table-condensed">
                    <thead>
                        <tr>
                            <th>1</th>
                            <th>2</th>
                            <th>3</th>
                            <th>4</th>
                            <th>5</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var att in Model)
                        {
                        <tr>
                            <td>@Html.DisplayFor(modelItem => att.1)</td>
                            <td>@Html.DisplayFor(modelItem => att.2)</td>
                            <td>@Html.DisplayFor(modelItem => att.3)</td>
                            <td>@Html.DisplayFor(modelItem => att.4)</td>
                            <td>@Html.DisplayFor(modelItem => att.5)</td>
                            <td>
                                <a asp-action="Edit" asp-route-id="@att.Id" class="btn btn-info"><i class="glyphicon glyphicon-pencil"></i>EDIT</a>
                                <a asp-action="DeleteCategory" asp-route-id="@att.Id" class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i>DELETE</a>
                            </td>
    
                        </tr>
                        }
                    </tbody>
                </table>
            </div>
        </div>
    </div>