diff --git a/test-browser/helpers/contracts.js b/test-browser/helpers/contracts.js index e4a71bdc69..9d687437a8 100644 --- a/test-browser/helpers/contracts.js +++ b/test-browser/helpers/contracts.js @@ -21,6 +21,7 @@ function testContracts (browser, contractCode, compiledContractNames, callback) .clearValue('#input textarea') .click('.newFile') .setValue('#input textarea', contractCode, function () {}) - .waitForElementPresent('.contract .create', 2000) - checkCompiledContracts(browser, compiledContractNames, callback) + .waitForElementPresent('.contract .create', 2000, true, function () { + checkCompiledContracts(browser, compiledContractNames, callback) + }) } diff --git a/test-browser/helpers/dom.js b/test-browser/helpers/dom.js new file mode 100644 index 0000000000..d1ba95aa1c --- /dev/null +++ b/test-browser/helpers/dom.js @@ -0,0 +1,20 @@ +'use strict' + +module.exports = { + listSelectorContains: listSelectorContains +} + +function listSelectorContains (textsToFind, selector, browser, callback) { + browser + .elements('css selector', selector, function (warnings) { + warnings.value.map(function (warning, index) { + browser.elementIdText(warning.ELEMENT, function (text) { + browser.assert.equal(text.value.indexOf(textsToFind[index]) !== -1, true) + if (index === warnings.value.length - 1) { + callback() + } + }) + }) + }) +} + diff --git a/test-browser/tests/staticanalysis.js b/test-browser/tests/staticanalysis.js index c0c1834c46..67fd0437b4 100644 --- a/test-browser/tests/staticanalysis.js +++ b/test-browser/tests/staticanalysis.js @@ -2,6 +2,7 @@ var contractHelper = require('../helpers/contracts') var init = require('../helpers/init') var sauce = require('./sauce') +var dom = require('../helpers/dom') var sources = { 'sources': { @@ -28,33 +29,22 @@ module.exports = { tearDown: sauce } -function findText (browser, selector, textToFind) { - var found = false - browser - .elements('css selector', selector, function (warnings) { - warnings.value.forEach(function (warning) { - browser.elementIdText(warning.ELEMENT, function (text) { - if (text.indexOf(textToFind) >= 0) { - found = true - } - }) - }) - }) - browser.assert.equal(found, true) -} - function runTests (browser) { browser .waitForElementVisible('.newFile', 10000) contractHelper.testContracts(browser, sources.sources.Untitled, ['TooMuchGas', 'test1', 'test2'], function () { + console.log('pppzzz?') browser .click('.staticanalysisView') .click('#staticanalysisView button') - .waitForElementPresent('#staticanalysisresult .warning') - findText(browser, '#staticanalysisresult .warning span', - 'Untitled:2:33: use of tx.origin') - findText(browser, '#staticanalysisresult .warning span', - 'Fallback function of contract TooMuchGas requires too much gas') - browser.end() + .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { + dom.listSelectorContains(['Untitled:1:34: use of tx.origin', + 'Fallback function of contract TooMuchGas requires too much gas'], + '#staticanalysisresult .warning span', + browser, function () { + browser.end() + } + ) + }) }) }