fix e2e: force select checkbox

pull/5370/head
yann300 3 years ago
parent 118b215fc6
commit 6e635f99ba
  1. 15
      apps/remix-ide-e2e/src/commands/clickElementAtPosition.ts
  2. 2
      apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts
  3. 2
      apps/remix-ide-e2e/src/types/index.d.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()
})
}

@ -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"]')

@ -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,

Loading…
Cancel
Save