> For the complete documentation index, see [llms.txt](https://help.autify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.autify.com/nocode-web/en/faq/faq-create-scenario/what-if-i-want-to-click-on-the.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# How do I interact with the elements in a table or list the way I intended?

Let's say you're creating a scenario. You've recorded an action against an element at the top of a table, and the element contains the text "test0001". Later, a new record is added and "test0001" is moved to the second row. Now, the first row is "test0002". When you run the scenario, Autify may target the "test0001" element in the second row, which is not what you intended.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-9dc31d4a0565f8215a9c2f6b0fce750964a8272e%2Fmoved_record.png?alt=media)

If the intended action is to always click the newest record at the top of the table, the test may fail in a subsequent step.

Currently, if you want to ensure that Autify targets the top, Nth, or bottom element in a list or table, you must use the [Locator](https://help.autify.com/nocode-web/en/autify-university/advanced/locator-feature/add-a-locator.md) feature.

Below are some examples of CSS selectors/XPaths that you can set as the Locator. Please note that the CSS selectors/XPaths shown in this article are examples. Be sure to check the actual structure of your site and create an appropriate CSS selector/XPath.

## Target the Nth Element With a CSS Selector

If you want to target the Nth element with a CSS selector, you can use the following syntax:

* Nth

```css
:nth-child(N)
```

* First

```css
:first-child
```

* Last

```css
:last-child
```

If you want to target the second item in a list, you can use the following syntax:

```css
ul > li:nth-child(2)
```

## Target an Element in the Nth Row, Mth Column of a Table

To target an item in a table, you must specify the row and column; the `tr` tag represents the row and the `td` tag represents the column. Specify the row and column of the element you want to access. The following is a CSS selector that gets the element in the first row of the first column. If the table has the most recent data at the top, this CSS selector will always target the most recent data.

```css
table > tbody > tr:first-child > td:first-child
```

In the example table below, the element in the red box is the target.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-98d08f91a96cbc108cdc20d0a927aab49fc33a66%2Ftd_a.png?alt=media)

The target element in the red box is a `td` element, but under this element is a link created with the `a` tag. If you want to click on this link, add `a` to the end of the CSS selector.

```css
table > tbody > tr:first-child > td:first-child a
```

You can also target the last column. To do this, change `td:first-child` to `td:last-child`, as shown below.

```css
table > tbody > tr:first-child > td:last-child
```

## Target a Specific Column of a Table Where a Row Contains a Specific Text

Instead of specifying the Nth row/Mth column, you may want to target a specific column, in the row that contains a specific text. For example, below is a table of Autify Scenarios. To target the last element in the row with the scenario name "test0001", you can use the following XPath:

```
//table/tbody/tr[td//*[text()='test0001']]/td[6]
```

The target is the `td` element in the green box:

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-98ce9e4add4fc41df82ef7bcb8af86efe15a04f3%2Ftd_with_specific_text.png?alt=media)

The target element is a `td` element, and under this element, there is a menu icon inside a `button` tag. If you want to target this `button` tag, change the XPath as follows:

```
//table/tbody/tr[td//*[text()='test0001']]/td[6]//button
```

If the text you want to find is not the same each time and is randomly generated for each test run using a [JS Step](https://help.autify.com/nocode-web/en/autify-university/advanced/js-steps/javascript-steps.md) or a [dynamic value](https://help.autify.com/nocode-web/en/autify-university/foundation/creating-a-scenario/dynamic-value-generation.md), you will need to use a JS Step. Get the string you want to find, which was created as an argument in another step, and use it in the following JS Snippet:

* [Search for text in a table and operate the specific column of the found row.](https://javascript-snippets.autify.com/snippets/others/search_in_table_and_operate_specific_column//)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.autify.com/nocode-web/en/faq/faq-create-scenario/what-if-i-want-to-click-on-the.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
