From 19361362b9ed0e6796c8d28ad3ade5082ff50f83 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 21 Sep 2022 16:06:52 +0200 Subject: [PATCH] fix command --- .../src/commands/debugTransaction.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/debugTransaction.ts b/apps/remix-ide-e2e/src/commands/debugTransaction.ts index 67955ea38d..2347d8d939 100644 --- a/apps/remix-ide-e2e/src/commands/debugTransaction.ts +++ b/apps/remix-ide-e2e/src/commands/debugTransaction.ts @@ -2,7 +2,7 @@ import { NightwatchBrowser } from 'nightwatch' import EventEmitter from 'events' class debugTransaction extends EventEmitter { - command (this: NightwatchBrowser, index = 0): NightwatchBrowser { + command(this: NightwatchBrowser, index = 0): NightwatchBrowser { this.api.perform((done) => { checkStyle(this.api, index, () => { done() @@ -13,14 +13,27 @@ class debugTransaction extends EventEmitter { } } -function checkStyle (browser: NightwatchBrowser, index: number, callback: VoidFunction) { - browser.pause(5000).execute(function (index: number) { +function checkStyle(browser: NightwatchBrowser, index: number, callback: VoidFunction) { + let elementsFound = 0 + browser.waitUntil(() => { + browser.findElements({ + selector: '*[data-shared="txLoggerDebugButton"]', + timeout: 60000, + }, (result) => { + if (Array.isArray(result.value) && result.value.length > 0) { + elementsFound = result.value.length + } + }) + return elementsFound > index + }, 60000) + .execute(function (index: number) { const debugBtn = document.querySelectorAll('*[data-shared="txLoggerDebugButton"]')[index] as HTMLInputElement debugBtn && debugBtn.click() }, [index], function () { browser.waitForElementVisible('*[data-id="buttonNavigatorJumpPreviousBreakpoint"]', 60000).perform(() => callback()) }) + } module.exports = debugTransaction