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: 0 additions & 1 deletion src/McpContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ export class McpContext implements Context {
const networkMultiplier = getNetworkMultiplierFromString(
this.getNetworkConditions(),
);

const waitForHelper = this.getWaitForHelper(
page,
cpuMultiplier,
Expand Down
20 changes: 12 additions & 8 deletions src/WaitForHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,22 @@ export class WaitForHelper {
async waitForEventsAfterAction(
action: () => Promise<unknown>,
): Promise<void> {
const navigationStartedPromise = this.waitForNavigationStarted();
const navigationFinished = this.waitForNavigationStarted()
.then(navigationStated => {
if (navigationStated) {
return this.#page.waitForNavigation({
timeout: this.#navigationTimeout,
signal: this.#abortController.signal,
});
}
return;
})
.catch(error => logger(error));

await action();

try {
const navigationStated = await navigationStartedPromise;
if (navigationStated) {
await this.#page.waitForNavigation({
timeout: this.#navigationTimeout,
signal: this.#abortController.signal,
});
}
await navigationFinished;

// Wait for stable dom after navigation so we execute in
// the correct context
Expand Down
Loading