Documentation Index
Fetch the complete documentation index at: https://trydent.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The content-script.js file serves a vital role in monitoring user interactions with a web page, gathering details about the elements involved, and transmitting this data to the extension’s background script and the Chrome DevTools panel. It tracks various types of events like ‘click’, ‘focus’, ‘blur’, and ‘change’. On detecting an event, it captures the details, including the target element’s XPath, and sends this information for further processing. This data aids in generating Cypress test code corresponding to the user interactions.Functions
getRelativeXPath(element)
ThegetRelativeXPath(element) function accepts an HTMLElement and returns its relative XPath. It prioritizes unique attributes like ‘data-cy’, ‘data-test’, ‘data-testid’, and ‘id’ when forming the XPath. If none of these unique attributes are available, it determines the element’s position amongst its siblings sharing the same tag name. For anchor tags with an href attribute, the function modifies global variables accordingly.
inputEventListener(event, callback)
TheinputEventListener(event, callback) function serves as an event listener for input events like ‘click’, ‘focus’, ‘blur’, and ‘change’. It takes an event object and a callback function as parameters. The function extracts relevant information from the event object, including the target element’s XPath and the event type, and calls the callback function with the obtained data. This function also handles ‘keydown’, ‘keyup’, and ‘mouseover’ events, enabling the user to trigger custom events using a specific combination of keys.
Event Listeners
The script sets up event listeners for ‘click’, ‘focus’, ‘blur’, ‘change’, ‘keydown’, ‘keyup’, and ‘mouseover’ events. It calls theinputEventListener() function for each event, which subsequently sends messages containing the event details to the background script and the DevTools panel.

