--- title: "Select the Nth of the options" slug: "select-the-nth-of-options" updated: 2024-04-16T01:38:23Z published: 2024-04-16T01:38:23Z canonical: "help.autify.com/select-the-nth-of-options" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.autify.com/llms.txt > Use this file to discover all available pages before exploring further. # Select the Nth option from a list ## Selecting the Nth Option from a List In a [Select a value from a list](/docs/select-from-list-by-label) step, the option is selected based on its label, so you cannot use it to select the Nth option. However, you can achieve the same action by combining "[JS Steps for Elements](/docs/js-steps-for-elements)" and the "Select a value from a list" step. Note The method described here cannot be used for lists that aren't implemented using the `<select>` element. ### Benefits of Using JS Steps for Elements Using a regular JS step, it's possible to select the Nth option from a list with a single JS step. However, on this page, we will show you how to combine "JS Steps for Elements" with the "Select a value from a list" step, as using "JS Steps for Elements" has the following advantages: - Autify AI gets the element, so you don't have to get its CSS selector/XPath. - Requires less code, since you don't need to write code to get the element. - Automatically waits for the page to finish loading and for the element to appear. ## Record and Edit the Scenario First, right-click on the target list and select ***[Autify Recorder]*** > ***[Add JS Step]***. Next, select the appropriate value from the list and click ***[Save]***. ![en_select_option_n_1.png.png](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/en_select_option_n_1.png.png?sv=2026-02-06&spr=https&st=2026-11-11T15%3A26%3A57Z&se=2026-11-11T16%3A26%3A57Z&sr=c&sp=r&sig=lM8Q9t13GCd7ICEcJwIN4I40WhWDrXqqZ5cUtyHITKM%3D) This will create two steps: "Execute JavaScript" (we'll call this step as "JS Step for Element") and "Select ... from List". ![en_select_option_n_2.png](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/en_select_option_n_2.png?sv=2026-02-06&spr=https&st=2026-11-11T15%3A26%3A57Z&se=2026-11-11T16%3A26%3A57Z&sr=c&sp=r&sig=lM8Q9t13GCd7ICEcJwIN4I40WhWDrXqqZ5cUtyHITKM%3D) Open the *JS Step for Element* and paste the following code. Autify will get the element, so less code is needed. ``` // The index of the list starts at 0, so if you want to select the fourth option, specify 3. const index = 3; // -- No need to change from here on down -- // Obtains the label with the specified index number. const label = element.options[index].label; // The obtained label is returned and made available for use in subsequent steps. return label; ``` The section below specifies the index number of the option. Since the index starts at 0, set it to 3 if you want to select the 4th option. ``` const index = 3; ``` Next, click the "Select ... from List" step, change the label value to "Other step's result", specify the *JS Step for Element*, and save. Now it will select the label obtained in the *JS Step for Element*. ![en_select_option_n_3.png](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/en_select_option_n_3.png?sv=2026-02-06&spr=https&st=2026-11-11T15%3A26%3A57Z&se=2026-11-11T16%3A26%3A57Z&sr=c&sp=r&sig=lM8Q9t13GCd7ICEcJwIN4I40WhWDrXqqZ5cUtyHITKM%3D) ## Run the Test Let's run the test. Looking at the result, we can confirm that the return value of the *JS Step for Element* is the expected label value. ![en_select_option_n_4.png](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/en_select_option_n_4.png?sv=2026-02-06&spr=https&st=2026-11-11T15%3A26%3A57Z&se=2026-11-11T16%3A26%3A57Z&sr=c&sp=r&sig=lM8Q9t13GCd7ICEcJwIN4I40WhWDrXqqZ5cUtyHITKM%3D) The list value is also changed to the returned value. ![en_select_option_n_5.png](https://cdn.document360.io/a099d8a2-cfd2-42ca-9906-68b4a337f4a5/Images/Documentation/en_select_option_n_5.png?sv=2026-02-06&spr=https&st=2026-11-11T15%3A26%3A57Z&se=2026-11-11T16%3A26%3A57Z&sr=c&sp=r&sig=lM8Q9t13GCd7ICEcJwIN4I40WhWDrXqqZ5cUtyHITKM%3D)