---
title: "Fix failing instructions with LLMs"
slug: "llms-fix-instructions"
updated: 2025-11-10T20:09:39Z
published: 2025-11-10T20:09:39Z
canonical: "success.panaya.com/llms-fix-instructions"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://success.panaya.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fix failing instructions with LLMs

By using ChatGPT, Copilot, or other LLM interfaces, you can identify the correct locator or generate JavaScript code to perform desired actions with Panaya’s ScriptBuilder and Agent, such as dynamically selecting dates from a calendar, clicking a button, expanding tree nodes, or picking a value from a dropdown list.

This article demonstrates how to use LLMs to achieve a specific activity simulation with the [Execute Code](/v1/docs/execute-code) instruction.

> [!WARNING]
> Before you proceed
> 
> We recommend trying to [update locators](/v1/docs/locators) or using [AI playback self-healing](/v1/docs/ai-playback-self-healing), before using external LLMs.

### Example Scenario

We encountered a unique calendar date object on a web page opened from a previous date picker action.

![Calendar example](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-KMGAGUJI.png)

ScriptBuilder was unable to select the date, and updating the locator did not resolve the issue.

![Locator failed](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-PNEOB851.png)

### Inspecting the Element

Using F12 Developer Tools, we inspect the calendar date element (for example, date 29):

![Inspecting element](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-ADEJB5M8.png)

Right-click the element and select **Copy → Copy Element**:

![Copy element](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-PUMMJTBG.png)

### Generating JavaScript Code with ChatGPT

In ChatGPT, paste the copied element and ask for JavaScript code to select the specific date (for example, October 29):

![Ask ChatGPT for JS code](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-TT27SAFC.png)

### Testing the Code

Paste the suggested code into the browser console. If prompted, type `allow pasting` and press Enter before running the code.

![Browser console test](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-YTYRSP2X.png)

If you receive an error such as “Could not find the date link for October 29,” return to the Elements tab and inspect the structure. You may notice the calendar is located within a form element, for example, `id="a"`:

![Form element](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-34B4HSYT.png)

Copy this parent element to provide additional context for ChatGPT:

![Copy form element](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-904YQ27B.png)

### Refining the Prompt

Update ChatGPT that the previous code did not work, and paste both the new element structure and any errors received. ChatGPT will then generate improved JavaScript code:

![ChatGPT feedback](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-9XUE2WFI.png)

![Updated JS code](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-GVBE70CU.png)

### Result

After pasting and running the new code in the console, the calendar selects the 29th and closes automatically. You can now reuse this code in an [Execute Code](/v1/docs/execute-code) instruction and turn off the original click instruction.

![Final success](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-5ICTK4EF.png)

A similar approach can also help you identify a working [locator](/v1/docs/locators) when the usual methods fail.

> [!NOTE]
> Disclaimer
> 
> This article is intended for informational purposes only. The use of large language models (LLMs) or any AI-based tools is at your own discretion and must align with your organization's policies on security, privacy, and data usage.
