Added custom command for element selection at position (index)

pull/5370/head
ioedeveloper 5 years ago committed by Aniket
parent 094707402e
commit 39bbece972
  1. 5
      ci/browser_tests.sh
  2. 24
      test-browser/commands/clickElementAtPosition.js
  3. 10
      test-browser/tests/solidityUnittests.js

@ -21,8 +21,9 @@ setupRemixd
sleep 5 sleep 5
npm run nightwatch_parallel || TEST_EXITCODE=1 npm run nightwatch_local_solidityUnitTests || TEST_EXITCODE=1
npm run nightwatch_local_runAndDeploy || TEST_EXITCODE=1 #npm run nightwatch_parallel || TEST_EXITCODE=1
#npm run nightwatch_local_runAndDeploy || TEST_EXITCODE=1
echo "$TEST_EXITCODE" echo "$TEST_EXITCODE"
if [ "$TEST_EXITCODE" -eq 1 ] if [ "$TEST_EXITCODE" -eq 1 ]

@ -0,0 +1,24 @@
const EventEmitter = require('events')
class ClickElement extends EventEmitter {
command (cssSelector, index = 0) {
this.api.perform((done) => {
_clickElement(this.api, cssSelector, index, () => {
done()
this.emit('complete')
})
})
return this
}
}
function _clickElement (browser, cssSelector, index, cb) {
browser.waitForElementPresent(cssSelector)
.execute(function (cssSelector, index) {
document.querySelectorAll(cssSelector)[index].click()
}, [cssSelector, index], function () {
cb()
})
}
module.exports = ClickElement

@ -42,7 +42,7 @@ module.exports = {
.click('*[data-id="verticalIconsKindsolidityUnitTesting"]') .click('*[data-id="verticalIconsKindsolidityUnitTesting"]')
.waitForElementPresent('*[data-id="testTabCheckAllTests"]') .waitForElementPresent('*[data-id="testTabCheckAllTests"]')
.click('*[data-id="testTabCheckAllTests"]') .click('*[data-id="testTabCheckAllTests"]')
.click('.singleTestLabel:nth-of-type(2)') .clickElementAtPosition('.singleTestLabel', 1)
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]') .scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]')
.pause(15000) .pause(15000)
.assert.containsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'browser/simple_storage_test.sol (MyTest)') .assert.containsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'browser/simple_storage_test.sol (MyTest)')
@ -60,7 +60,7 @@ module.exports = {
.click('*[data-id="verticalIconsKindsolidityUnitTesting"]') .click('*[data-id="verticalIconsKindsolidityUnitTesting"]')
.waitForElementPresent('*[data-id="testTabCheckAllTests"]') .waitForElementPresent('*[data-id="testTabCheckAllTests"]')
.click('*[data-id="testTabCheckAllTests"]') .click('*[data-id="testTabCheckAllTests"]')
.click('.singleTestLabel:nth-of-type(3)') .clickElementAtPosition('.singleTestLabel', 2)
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]') .scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]')
.pause(20000) .pause(20000)
.assert.containsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'browser/ks2b_test.sol (kickstarterTest)') .assert.containsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'browser/ks2b_test.sol (kickstarterTest)')
@ -81,7 +81,7 @@ module.exports = {
.switchFile('browser/compilationError_test.sol') .switchFile('browser/compilationError_test.sol')
.clickLaunchIcon('solidityUnitTesting') .clickLaunchIcon('solidityUnitTesting')
.click('*[data-id="testTabCheckAllTests"]') .click('*[data-id="testTabCheckAllTests"]')
.click('.singleTestLabel:nth-of-type(4)') .clickElementAtPosition('.singleTestLabel', 3)
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]') .scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]')
.pause(10000) .pause(10000)
.waitForElementPresent('*[data-id="testTabSolidityUnitTestsSummary"]') .waitForElementPresent('*[data-id="testTabSolidityUnitTestsSummary"]')
@ -95,7 +95,7 @@ module.exports = {
.switchFile('browser/deployError_test.sol') .switchFile('browser/deployError_test.sol')
.clickLaunchIcon('solidityUnitTesting') .clickLaunchIcon('solidityUnitTesting')
.click('*[data-id="testTabCheckAllTests"]') .click('*[data-id="testTabCheckAllTests"]')
.click('.singleTestLabel:nth-of-type(5)') .clickElementAtPosition('.singleTestLabel', 4)
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]') .scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]')
.pause(10000) .pause(10000)
.waitForElementPresent('*[data-id="testTabSolidityUnitTestsSummary"]') .waitForElementPresent('*[data-id="testTabSolidityUnitTestsSummary"]')
@ -109,7 +109,7 @@ module.exports = {
.switchFile('browser/methodFailure_test.sol') .switchFile('browser/methodFailure_test.sol')
.clickLaunchIcon('solidityUnitTesting') .clickLaunchIcon('solidityUnitTesting')
.click('*[data-id="testTabCheckAllTests"]') .click('*[data-id="testTabCheckAllTests"]')
.click('.singleTestLabel:nth-of-type(6)') .clickElementAtPosition('.singleTestLabel', 5)
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]') .scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]')
.pause(15000) .pause(15000)
.waitForElementPresent('*[data-id="testTabSolidityUnitTestsSummary"]') .waitForElementPresent('*[data-id="testTabSolidityUnitTestsSummary"]')

Loading…
Cancel
Save