From 8d0f783b41d6c188efda524ec91fcc1bbf2725ae Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Sep 2022 16:08:44 +0200 Subject: [PATCH] add file --- apps/remix-ide-e2e/src/commands/addFile.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/addFile.ts b/apps/remix-ide-e2e/src/commands/addFile.ts index f9536bb259..a1aa1a5948 100644 --- a/apps/remix-ide-e2e/src/commands/addFile.ts +++ b/apps/remix-ide-e2e/src/commands/addFile.ts @@ -2,7 +2,7 @@ import { NightwatchBrowser, NightwatchContractContent } from 'nightwatch' import EventEmitter from 'events' class AddFile extends EventEmitter { - command (this: NightwatchBrowser, name: string, content: NightwatchContractContent): NightwatchBrowser { + command(this: NightwatchBrowser, name: string, content: NightwatchContractContent): NightwatchBrowser { this.api.perform((done) => { addFile(this.api, name, content, () => { done() @@ -13,9 +13,18 @@ class AddFile extends EventEmitter { } } -function addFile (browser: NightwatchBrowser, name: string, content: NightwatchContractContent, done: VoidFunction) { - browser.clickLaunchIcon('udapp') - .clickLaunchIcon('filePanel') +function addFile(browser: NightwatchBrowser, name: string, content: NightwatchContractContent, done: VoidFunction) { + browser + .isVisible({ + selector: "//*[@data-id='sidePanelSwapitTitle' and contains(.,'File explorer')]", + locateStrategy: 'xpath', + suppressNotFoundErrors: true, + timeout: 1000 + }, (okVisible) => { + if (!okVisible.value) { + browser.clickLaunchIcon('filePanel') + } + }) .waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') .click('li[data-id="treeViewLitreeViewItemREADME.txt"]').pause(1000) // focus on root directory .elements('css selector', `li[data-id="treeViewLitreeViewItem${name}"]`, (res) => {