From c16faae2ec201f306237fe5d3bd53cc8380f8096 Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Thu, 14 Mar 2019 17:24:23 +0100 Subject: [PATCH 1/2] fxied issue 1561 --- lib/command/definitions.js | 4 ++-- lib/helper/WebDriver.js | 2 +- lib/parser.js | 2 +- lib/utils.js | 2 +- test/helper/WebDriver_test.js | 7 +++++++ 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/command/definitions.js b/lib/command/definitions.js index 96b1afdd9..fdfd5eeae 100644 --- a/lib/command/definitions.js +++ b/lib/command/definitions.js @@ -206,9 +206,9 @@ module.exports = function (genPath, options) { function addAllMethodsInObject(supportObj, actions, methods, translations) { for (const action of methodsOfObject(supportObj)) { - let fn = supportObj[action]; + const fn = supportObj[action]; if (!fn.name) { - Object.defineProperty(fn, "name", {value: action}); + Object.defineProperty(fn, 'name', { value: action }); } const actionAlias = translations ? translations.actionAliasFor(action) : action; if (!actions[actionAlias]) { diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 573bad4a3..5d09f9e04 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -1950,7 +1950,7 @@ async function proceedSee(assertType, text, context, strict = false) { const selected = await forEachAsync(res, async el => this.browser.getElementText(getElementId(el))); if (strict) { - if (Array.isArray(selected)) { + if (Array.isArray(selected) && selected.length !== 0) { return selected.map(elText => equals(description)[assertType](text, elText)); } return equals(description)[assertType](text, selected); diff --git a/lib/parser.js b/lib/parser.js index 7583eb050..99eaa4460 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -87,7 +87,7 @@ function getParams(fn) { }); return params; } catch (err) { - console.log('Error in ' + newFn.toString()); + console.log(`Error in ${newFn.toString()}`); console.error(err); } } diff --git a/lib/utils.js b/lib/utils.js index 1f02abd7c..9b6b5c28e 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -40,7 +40,7 @@ const isGenerator = module.exports.isGenerator = function (fn) { }; const isFunction = module.exports.isFunction = function (fn) { - return typeof fn === 'function' + return typeof fn === 'function'; }; const isAsyncFunction = module.exports.isAsyncFunction = function (fn) { diff --git a/test/helper/WebDriver_test.js b/test/helper/WebDriver_test.js index ea8ba3000..a6156b1bb 100644 --- a/test/helper/WebDriver_test.js +++ b/test/helper/WebDriver_test.js @@ -198,6 +198,13 @@ describe('WebDriver', function () { // e.should.be.instanceOf(AssertionFailedError); // e.inspect().should.include("expected element h1 'Welcome to test app' to equal 'Welcome to test app!'"); })); + + it.only('should check text is not equal to empty string of element text', () => wd.amOnPage('https://codecept.discourse.group/') + .then(() => wd.seeTextEquals('This is not empty', '[id="site-logo"]')) + .catch((e) => { + e.should.be.instanceOf(Error); + e.message.should.be.equal('expected element [id="site-logo"] "This is not empty" to equal ""'); + })); }); describe('#waitForFunction', () => { From abe75807b0883a6c31143e4c21aadbcb207b27d5 Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Thu, 14 Mar 2019 18:08:35 +0100 Subject: [PATCH 2/2] removed only :) --- test/helper/WebDriver_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helper/WebDriver_test.js b/test/helper/WebDriver_test.js index a6156b1bb..b8e25f872 100644 --- a/test/helper/WebDriver_test.js +++ b/test/helper/WebDriver_test.js @@ -199,7 +199,7 @@ describe('WebDriver', function () { // e.inspect().should.include("expected element h1 'Welcome to test app' to equal 'Welcome to test app!'"); })); - it.only('should check text is not equal to empty string of element text', () => wd.amOnPage('https://codecept.discourse.group/') + it('should check text is not equal to empty string of element text', () => wd.amOnPage('https://codecept.discourse.group/') .then(() => wd.seeTextEquals('This is not empty', '[id="site-logo"]')) .catch((e) => { e.should.be.instanceOf(Error);