diff --git a/apps/remix-ide-e2e/src/commands/clickElementAtPosition.ts b/apps/remix-ide-e2e/src/commands/clickElementAtPosition.ts index 289f8da83b..ab36d91f5f 100644 --- a/apps/remix-ide-e2e/src/commands/clickElementAtPosition.ts +++ b/apps/remix-ide-e2e/src/commands/clickElementAtPosition.ts @@ -2,9 +2,9 @@ import { NightwatchBrowser } from 'nightwatch' import EventEmitter from 'events' class ClickElement extends EventEmitter { - command (this: NightwatchBrowser, cssSelector: string, index = 0): NightwatchBrowser { + command (this: NightwatchBrowser, cssSelector: string, index = 0 , opt = { forceSelectIfUnselected: false }): NightwatchBrowser { this.api.perform((done) => { - _clickElement(this.api, cssSelector, index, () => { + _clickElement(this.api, cssSelector, index, opt.forceSelectIfUnselected, () => { done() this.emit('complete') }) @@ -13,13 +13,14 @@ class ClickElement extends EventEmitter { } } -function _clickElement (browser: NightwatchBrowser, cssSelector: string, index: number, cb: VoidFunction) { +function _clickElement (browser: NightwatchBrowser, cssSelector: string, index: number, forceSelectIfUnselected: boolean, cb: VoidFunction) { browser.waitForElementPresent(cssSelector) - .execute(function (cssSelector: string, index: number) { + .execute(function (cssSelector: string, index: number, forceSelectIfUnselected: boolean) { const elem = document.querySelectorAll(cssSelector)[index] as HTMLElement - - elem.click() - }, [cssSelector, index], function () { + if (forceSelectIfUnselected) { + if (!(elem as any).checked) elem.click() + } else elem.click() + }, [cssSelector, index, forceSelectIfUnselected], function () { cb() }) } diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index 83e2234670..db730183cd 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -140,7 +140,7 @@ module.exports = { .clickLaunchIcon('solidityUnitTesting') .setValue('*[data-id="uiPathInput"]', 'myTests') .click('*[data-id="testTabGenerateTestFolder"]') - .clickElementAtPosition('.singleTestLabel', 0) + .clickElementAtPosition('.singleTestLabel', 0, { forceSelectIfUnselected: true }) .scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]') .waitForElementPresent('*[data-id="testTabSolidityUnitTestsOutputheader"]', 60000) .waitForElementPresent('*[data-id="testTabSolidityUnitTestsOutput"]') diff --git a/apps/remix-ide-e2e/src/types/index.d.ts b/apps/remix-ide-e2e/src/types/index.d.ts index 55091bc0a8..49688472cc 100644 --- a/apps/remix-ide-e2e/src/types/index.d.ts +++ b/apps/remix-ide-e2e/src/types/index.d.ts @@ -46,7 +46,7 @@ declare module 'nightwatch' { setupMetamask(passphrase: string, password: string): NightwatchBrowser, signMessage(msg: string, callback: (hash: { value: string }, signature: { value: string }) => void): NightwatchBrowser, setSolidityCompilerVersion(version: string): NightwatchBrowser, - clickElementAtPosition(cssSelector: string, index: number): NightwatchBrowser, + clickElementAtPosition(cssSelector: string, index: number, opt?: { forceSelectIfUnselected: boolean }): NightwatchBrowser, notContainsText(cssSelector: string, text: string): NightwatchBrowser, sendLowLevelTx(address: string, value: string, callData: string): NightwatchBrowser, journalLastChild(val: string): NightwatchBrowser,