From 4878e124264e4dd3f7fa60db9b64c5e420342765 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 23 Oct 2017 19:06:36 +0200 Subject: [PATCH] improve tests --- test-browser/helpers/dom.js | 26 +++++++++++++++----------- test-browser/tests/staticanalysis.js | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/test-browser/helpers/dom.js b/test-browser/helpers/dom.js index d1ba95aa1c..e1ef02413e 100644 --- a/test-browser/helpers/dom.js +++ b/test-browser/helpers/dom.js @@ -5,16 +5,20 @@ module.exports = { } 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() - } - }) - }) - }) + browser.execute(function (selector) { + var items = document.querySelectorAll(selector) + var ret = [] + for (var k = 0; k < items.length; k++) { + ret.push(items[k].innerText) + } + return ret + }, [selector], function (result) { + console.log(result.value) + for (var k in textsToFind) { + console.log('testing ' + result.value[k] + ' against ' + textsToFind[k]) + browser.assert.equal(result.value[k].indexOf(textsToFind[k]) !== -1, true) + } + callback() + }) } diff --git a/test-browser/tests/staticanalysis.js b/test-browser/tests/staticanalysis.js index 62f7b1aea7..d0174ddfa1 100644 --- a/test-browser/tests/staticanalysis.js +++ b/test-browser/tests/staticanalysis.js @@ -39,7 +39,7 @@ function runTests (browser) { .waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () { dom.listSelectorContains(['browser/Untitled.sol:2:33: Use of tx.origin', 'Fallback function of contract browser/Untitled.sol:TooMuchGas requires too much gas'], - '#staticanalysisresult .warning span', + '#staticanalysisresult .warning', browser, function () { browser.end() }