Skip to content

Commit

Permalink
Added custom command for element selection at position (index)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioedeveloper authored and Aniket-Engg committed Apr 24, 2020
1 parent b4d51ca commit 6cc2b5e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
5 changes: 3 additions & 2 deletions ci/browser_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ setupRemixd

sleep 5

npm run nightwatch_parallel || TEST_EXITCODE=1
npm run nightwatch_local_runAndDeploy || TEST_EXITCODE=1
npm run nightwatch_local_solidityUnitTests || TEST_EXITCODE=1
#npm run nightwatch_parallel || TEST_EXITCODE=1
#npm run nightwatch_local_runAndDeploy || TEST_EXITCODE=1

echo "$TEST_EXITCODE"
if [ "$TEST_EXITCODE" -eq 1 ]
Expand Down
24 changes: 24 additions & 0 deletions test-browser/commands/clickElementAtPosition.js
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions test-browser/tests/solidityUnittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
.click('*[data-id="verticalIconsKindsolidityUnitTesting"]')
.waitForElementPresent('*[data-id="testTabCheckAllTests"]')
.click('*[data-id="testTabCheckAllTests"]')
.click('.singleTestLabel:nth-of-type(2)')
.clickElementAtPosition('.singleTestLabel', 1)
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]')
.pause(15000)
.assert.containsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'browser/simple_storage_test.sol (MyTest)')
Expand All @@ -60,7 +60,7 @@ module.exports = {
.click('*[data-id="verticalIconsKindsolidityUnitTesting"]')
.waitForElementPresent('*[data-id="testTabCheckAllTests"]')
.click('*[data-id="testTabCheckAllTests"]')
.click('.singleTestLabel:nth-of-type(3)')
.clickElementAtPosition('.singleTestLabel', 2)
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]')
.pause(20000)
.assert.containsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'browser/ks2b_test.sol (kickstarterTest)')
Expand All @@ -81,7 +81,7 @@ module.exports = {
.switchFile('browser/compilationError_test.sol')
.clickLaunchIcon('solidityUnitTesting')
.click('*[data-id="testTabCheckAllTests"]')
.click('.singleTestLabel:nth-of-type(4)')
.clickElementAtPosition('.singleTestLabel', 3)
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]')
.pause(10000)
.waitForElementPresent('*[data-id="testTabSolidityUnitTestsSummary"]')
Expand All @@ -95,7 +95,7 @@ module.exports = {
.switchFile('browser/deployError_test.sol')
.clickLaunchIcon('solidityUnitTesting')
.click('*[data-id="testTabCheckAllTests"]')
.click('.singleTestLabel:nth-of-type(5)')
.clickElementAtPosition('.singleTestLabel', 4)
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]')
.pause(10000)
.waitForElementPresent('*[data-id="testTabSolidityUnitTestsSummary"]')
Expand All @@ -109,7 +109,7 @@ module.exports = {
.switchFile('browser/methodFailure_test.sol')
.clickLaunchIcon('solidityUnitTesting')
.click('*[data-id="testTabCheckAllTests"]')
.click('.singleTestLabel:nth-of-type(6)')
.clickElementAtPosition('.singleTestLabel', 5)
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]')
.pause(15000)
.waitForElementPresent('*[data-id="testTabSolidityUnitTestsSummary"]')
Expand Down

0 comments on commit 6cc2b5e

Please sign in to comment.