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 instruction.
Before you proceed
We recommend trying to update locators or using 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.

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

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

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

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):

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

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":

Copy this parent element to provide additional context for ChatGPT:

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:


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 instruction and turn off the original click instruction.

A similar approach can also help you identify a working locator when the usual methods fail.
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.