Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to the full browser extension will be documented in this fil

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Umreleased
### Added
- Report `textarea` and `select` elements.

## 0.1.9 - 2026-05-15

### Added
Expand Down
6 changes: 6 additions & 0 deletions source/ContentScript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ function reportPointerElements(
const url = window.location.href;
if (
tagName !== 'input' &&
tagName !== 'textarea' &&
tagName !== 'select' &&
tagName !== 'button' &&
tagName !== 'a' &&
element instanceof Element
Expand All @@ -217,6 +219,8 @@ function reportPageLoaded(
reportPageLinks(doc, fn);
reportPageForms(doc, fn);
reportElements(doc.getElementsByTagName('input'), fn);
reportElements(doc.getElementsByTagName('textarea'), fn);
reportElements(doc.getElementsByTagName('select'), fn);
reportElements(doc.getElementsByTagName('button'), fn);
reportPointerElements(doc, fn);
reportStorage(LOCAL_STORAGE, localStorage, fn);
Expand All @@ -235,6 +239,8 @@ const domMutated = function domMutation(
for (const mutation of mutationList) {
if (mutation.type === 'childList') {
reportNodeElements(mutation.target, 'input', reportObject);
reportNodeElements(mutation.target, 'textarea', reportObject);
reportNodeElements(mutation.target, 'select', reportObject);
reportNodeElements(mutation.target, 'button', reportObject);
if (mutation.target.nodeType === Node.ELEMENT_NODE) {
reportPointerElements(mutation.target as Element, reportObject);
Expand Down
14 changes: 14 additions & 0 deletions source/types/ReportedModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ class ReportedElement extends ReportedObject {
// This will not work if form tags are not used
this.formId = Array.prototype.slice.call(document.forms).indexOf(form);
}
} else if (element.tagName === 'TEXTAREA') {
const textarea: HTMLTextAreaElement = element as HTMLTextAreaElement;
this.text = textarea.value;
const {form} = textarea;
if (form) {
this.formId = Array.prototype.slice.call(document.forms).indexOf(form);
}
} else if (element.tagName === 'SELECT') {
const select: HTMLSelectElement = element as HTMLSelectElement;
this.text = select.value;
const {form} = select;
if (form) {
this.formId = Array.prototype.slice.call(document.forms).indexOf(form);
}
} else if (element.hasAttribute('href')) {
this.href = element.getAttribute('href');
}
Expand Down
53 changes: 53 additions & 0 deletions test/ContentScript/integrationTests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,59 @@ function integrationTests(
]);
});

test('Should report textarea', async () => {
// Given
await enableZapEvents(server, driver);
const wd = await driver.getWebDriver();
// When
await wd.get(`http://localhost:${_HTTPPORT}/webpages/interactions.html`);
await eventsProcessed();
// Then
expect(actualData).toContainEqual(
reportObject(
'nodeAdded',
'TEXTAREA',
'textarea-1',
'TEXTAREA',
`http://localhost:${_HTTPPORT}/webpages/interactions.html`,
undefined,
'Existing text'
)
);
});

test('Should report select', async () => {
// Given
await enableZapEvents(server, driver);
const wd = await driver.getWebDriver();
// When
await wd.get(`http://localhost:${_HTTPPORT}/webpages/interactions.html`);
await eventsProcessed();
// Then
expect(actualData).toContainEqual(
reportObject(
'nodeAdded',
'SELECT',
'cars',
'SELECT',
`http://localhost:${_HTTPPORT}/webpages/interactions.html`,
undefined,
'volvo'
)
);
expect(actualData).toContainEqual(
reportObject(
'nodeAdded',
'SELECT',
'longlist',
'SELECT',
`http://localhost:${_HTTPPORT}/webpages/interactions.html`,
undefined,
'v01'
)
);
});

test('Should use className for input with stable unique class', async () => {
// Given / When
await driver.toggleRecording();
Expand Down
Loading