From faf46e4447508715a481c029c693266972770e10 Mon Sep 17 00:00:00 2001 From: Kazuhito Yokoi Date: Tue, 14 Jan 2020 16:37:43 +0900 Subject: [PATCH] Improve node files for UI testing --- .../nodes/core/function/10-function_page.js | 7 +++---- .../nodes/core/function/15-change_page.js | 16 ++++++++-------- .../nodes/core/function/80-template_page.js | 12 +++++------- .../nodes/core/network/10-mqttconfig_page.js | 4 ++-- test/editor/pageobjects/nodes/node_page.js | 4 ++-- test/editor/wdio.conf.js | 14 +++++++------- 6 files changed, 27 insertions(+), 30 deletions(-) diff --git a/test/editor/pageobjects/nodes/core/function/10-function_page.js b/test/editor/pageobjects/nodes/core/function/10-function_page.js index f39aba912..c1bb80a80 100644 --- a/test/editor/pageobjects/nodes/core/function/10-function_page.js +++ b/test/editor/pageobjects/nodes/core/function/10-function_page.js @@ -26,12 +26,11 @@ function functionNode(id) { util.inherits(functionNode, nodePage); -functionNode.prototype.setFunction = function(func) { +functionNode.prototype.setFunction = function (func) { browser.clickWithWait('#node-input-func-editor'); browser.keys(keyPage.selectAll()); - for (var i = 0; i < func.length; i++) { - browser.keys([func.charAt(i)]); - } + browser.keys(['Delete']); + browser.keys(func); // Delete the unnecessary code that ace editor does the autocompletion. browser.keys(keyPage.selectToEnd()); browser.keys(['Delete']); diff --git a/test/editor/pageobjects/nodes/core/function/15-change_page.js b/test/editor/pageobjects/nodes/core/function/15-change_page.js index 82441c9bc..8e72afe38 100644 --- a/test/editor/pageobjects/nodes/core/function/15-change_page.js +++ b/test/editor/pageobjects/nodes/core/function/15-change_page.js @@ -49,8 +49,8 @@ function setT(t, index) { } // It is better to create a function whose input value is the object type in the future, -changeNode.prototype.ruleSet = function(p, pt, to, tot, index) { - index = index ? index : 1; +changeNode.prototype.ruleSet = function (p, pt, to, tot, index) { + index = index || 1; setT("set", index); if (pt) { browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]'); @@ -68,23 +68,23 @@ changeNode.prototype.ruleSet = function(p, pt, to, tot, index) { browser.clickWithWait(totXPath); } if (to) { - browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[2]/div[2]/div/input' , to); + browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[2]/div[2]/div/input', to); } } -changeNode.prototype.ruleDelete = function(index) { - index = index ? index : 1; +changeNode.prototype.ruleDelete = function (index) { + index = index || 1; setT("delete", index); } -changeNode.prototype.ruleMove = function(p, to, index) { - index = index ? index : 1; +changeNode.prototype.ruleMove = function (p, to, index) { + index = index || 1; setT("move", index); browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', p); browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[4]/div[2]/div/input', to); } -changeNode.prototype.addRule = function() { +changeNode.prototype.addRule = function () { browser.clickWithWait('//*[@id="dialog-form"]/div[3]/div/a'); } diff --git a/test/editor/pageobjects/nodes/core/function/80-template_page.js b/test/editor/pageobjects/nodes/core/function/80-template_page.js index 68cf46acf..bf1786ba2 100644 --- a/test/editor/pageobjects/nodes/core/function/80-template_page.js +++ b/test/editor/pageobjects/nodes/core/function/80-template_page.js @@ -26,21 +26,19 @@ function templateNode(id) { util.inherits(templateNode, nodePage); -templateNode.prototype.setSyntax = function(syntax) { +templateNode.prototype.setSyntax = function (syntax) { browser.selectWithWait('#node-input-syntax', syntax); } -templateNode.prototype.setFormat = function(format) { +templateNode.prototype.setFormat = function (format) { browser.selectWithWait('#node-input-format', format); } -templateNode.prototype.setTemplate = function(template) { +templateNode.prototype.setTemplate = function (template) { browser.clickWithWait('#node-input-template-editor'); browser.keys(keyPage.selectAll()); - // Need to add a character one by one since some words such as 'Control' are treated as a special word. - for (var i = 0; i < template.length; i++) { - browser.keys([template.charAt(i)]); - } + browser.keys(['Delete']); + browser.keys(template); browser.keys(keyPage.selectToEnd()); browser.keys(['Delete']); // Need to wait until ace editor correctly checks the syntax. diff --git a/test/editor/pageobjects/nodes/core/network/10-mqttconfig_page.js b/test/editor/pageobjects/nodes/core/network/10-mqttconfig_page.js index 3266a1bd3..c7cdc90c5 100644 --- a/test/editor/pageobjects/nodes/core/network/10-mqttconfig_page.js +++ b/test/editor/pageobjects/nodes/core/network/10-mqttconfig_page.js @@ -23,14 +23,14 @@ function setServer(broker, port) { function clickOk() { browser.clickWithWait('#node-config-dialog-ok'); // Wait until an config dialog closes. - browser.waitForVisible('#node-config-dialog-ok', 4000, true); + browser.waitForVisible('#node-config-dialog-ok', 10000, true); } function edit() { browser.waitForVisible('#node-input-lookup-broker'); browser.click('#node-input-lookup-broker'); // Wait until a config dialog opens. - browser.waitForVisible('#node-config-dialog-ok', 4000); + browser.waitForVisible('#node-config-dialog-ok', 10000); } module.exports = { diff --git a/test/editor/pageobjects/nodes/node_page.js b/test/editor/pageobjects/nodes/node_page.js index 5234362ae..123c1cc9d 100644 --- a/test/editor/pageobjects/nodes/node_page.js +++ b/test/editor/pageobjects/nodes/node_page.js @@ -22,13 +22,13 @@ Node.prototype.edit = function() { browser.clickWithWait(this.id); browser.clickWithWait(this.id); // Wait until an edit dialog opens. - browser.waitForVisible('#node-dialog-ok', 4000); + browser.waitForVisible('#node-dialog-ok', 10000); } Node.prototype.clickOk = function() { browser.clickWithWait('#node-dialog-ok'); // Wait untile an edit dialog closes. - browser.waitForVisible('#node-dialog-ok', 4000, true); + browser.waitForVisible('#node-dialog-ok', 10000, true); browser.pause(50); } diff --git a/test/editor/wdio.conf.js b/test/editor/wdio.conf.js index 26d30570f..7bbfcbe24 100644 --- a/test/editor/wdio.conf.js +++ b/test/editor/wdio.conf.js @@ -15,7 +15,7 @@ **/ exports.config = { - + // // ================== // Specify Test Files @@ -150,12 +150,12 @@ exports.config = { // The only one supported by default is 'dot' // see also: http://webdriver.io/guide/reporters/dot.html reporters: ['spec'], - + // // Options to be passed to Mocha. // See the full list at http://mochajs.org/ mochaOpts: { - timeout: 60000, + timeout: 100000, ui: 'bdd' }, // @@ -197,7 +197,7 @@ exports.config = { */ // beforeCommand: function (commandName, args) { // }, - + /** * Hook that gets executed before the suite starts * @param {Object} suite suite details @@ -217,13 +217,13 @@ exports.config = { // beforeHook: function () { // }, /** - * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling + * Hook that gets executed _after_ a hook within the suite ends (e.g. runs after calling * afterEach in Mocha) */ // afterHook: function () { // }, /** - * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts. + * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) ends. * @param {Object} test test details */ // afterTest: function (test) { @@ -234,7 +234,7 @@ exports.config = { */ // afterSuite: function (suite) { // }, - + /** * Runs after a WebdriverIO command gets executed * @param {String} commandName hook command name