Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Fixed
- Ignore events on non-visible elements, which will fail on replay.
- Ignore click after submit, since the former is a side effect of the latter.

## 0.1.7 - 2025-11-28

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rec.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Fixed
- Ignore events on non-visible elements, which will fail on replay.
- Ignore click after submit, since the former is a side effect of the latter.

## 0.1.7 - 2025-11-28

Expand Down
9 changes: 9 additions & 0 deletions source/ContentScript/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ class Recorder {
this.handleFrameSwitches(level, frame);
console.log(event, 'ZAP clicked');
const elementLocator = getPath(event.target as HTMLElement, element);

if ((event as MouseEvent).detail === 0) {
// Not a user click.
if (this.cachedSubmit) {
this.handleCachedSubmit();
}
return;
}

this.sendZestScriptToZAP(
new ZestStatementElementScrollTo(elementLocator, waited),
false
Expand Down
26 changes: 23 additions & 3 deletions test/ContentScript/integrationTests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,29 @@ function integrationTests(
reportZestStatementScrollTo(3, 'visibleButton'),
reportZestStatementClick(4, 'visibleButton'),
reportZestStatementScrollTo(5, 'visibleCheckBox'),
reportZestStatementClick(6, 'visibleCheckBox'),
reportZestStatementScrollTo(7, 'visibleCheckBox'),
reportZestStatementSendKeys(8, 'visibleCheckBox', 'on', 'id'),
reportZestStatementSendKeys(6, 'visibleCheckBox', 'on', 'id'),
]);
});

test('Should not record click before submit', async () => {
// Given / When
await driver.toggleRecording();
const wd = await driver.getWebDriver();
await wd.get(`http://localhost:${_HTTPPORT}/webpages/submitClick.html`);
const input = await wd.findElement(By.id('input'));
await input.sendKeys('value');
await input.sendKeys(Key.ENTER);
await eventsProcessed();
// Then
expect(actualData).toEqual([
reportZestStatementComment(),
reportZestStatementLaunch(
'http://localhost:1801/webpages/submitClick.html'
),
reportZestStatementScrollTo(3, 'input'),
reportZestStatementSendKeys(4, 'input', 'value'),
reportZestStatementScrollTo(5, 'input'),
reportZestStatementSubmit(6, 'input'),
]);
});

Expand Down
12 changes: 12 additions & 0 deletions test/ContentScript/webpages/submitClick.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Submit and Click</title>
</head>
<body>
<form>
<input id="input" type="text">
<button id="submit" type="submit">Click Me</button>
</form>
</body>
</html>