From 377f71d421f4445b8e3a88b8b679481b62598221 Mon Sep 17 00:00:00 2001
From: bunsenstraat <filip.mertens@ethereum.org>
Date: Tue, 11 Feb 2025 15:36:37 +0100
Subject: [PATCH] fix cmd

---
 apps/remix-ide-e2e/src/commands/switchBrowserTab.ts | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/apps/remix-ide-e2e/src/commands/switchBrowserTab.ts b/apps/remix-ide-e2e/src/commands/switchBrowserTab.ts
index 76db38f0aaa..f203e8f7253 100644
--- a/apps/remix-ide-e2e/src/commands/switchBrowserTab.ts
+++ b/apps/remix-ide-e2e/src/commands/switchBrowserTab.ts
@@ -6,11 +6,13 @@ import EventEmitter from 'events'
 */
 
 class SwitchBrowserTab extends EventEmitter {
-  command (this: NightwatchBrowser, index: number): NightwatchBrowser {
+  command(this: NightwatchBrowser, index: number): NightwatchBrowser {
     this.api.perform((browser: NightwatchAPI, done) => {
       browser.windowHandles((result) => {
         console.log('switching to window', result)
-        browser.switchWindow(result.value[index])
+        if (Array.isArray(result.value)) {
+          browser.switchWindow(result.value[result.value[index] ? index : 0])
+        }
         done()
       })
       this.emit('complete')