Add page objects for UI testing (#2501)

* Update page object of change node

* Support multiple node outputs in UI testing

* Add page object of switch node

* Add page objects of trigger and exec nodes

* Remove unnecessary code

* Update page object of trigger node to select time unit

* Add page objects of websocket nodes

* Support boolean as value in selectWithWait()

* Update page object of split node

* Merge page objects of mqtt nodes to make them same as original mqtt node file path
This commit is contained in:
Kazuhito Yokoi
2020-03-13 22:20:16 +09:00
committed by GitHub
parent 6a30f2cbc8
commit 421b5846f2
16 changed files with 558 additions and 83 deletions

View File

@@ -18,8 +18,6 @@ var util = require("util");
var nodePage = require("../../node_page");
var keyPage = require("../../../util/key_page");
function debugNode(id) {
nodePage.call(this, id);
}

View File

@@ -0,0 +1,234 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
var util = require('util');
var nodePage = require('../../node_page');
function switchNode(id) {
nodePage.call(this, id);
}
util.inherits(switchNode, nodePage);
var vtType = {
"msg": 1,
"flow": 2,
"global": 3,
"str": 4,
"num": 5,
"jsonata": 6,
"env": 7,
"prev": 8
};
function setT(t, index) {
browser.selectWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/select', t);
}
function setV(v, vt, index) {
if (vt) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + vtType[vt] + ']');
}
if (v) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', v);
}
}
function setBetweenV(v, vt, v2, v2t, index) {
if (vt) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + vtType[vt] + ']');
}
if (v) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/div[1]/input', v);
}
if (v2t) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + vtType[v2t] + ']');
}
if (v2) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div/div[1]/input', v2);
}
}
function setSequenceV(v, vt, index) {
var sType = {
"flow": 1,
"global": 2,
"num": 3,
"jsonata": 4,
"env": 5,
};
if (vt) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + sType[vt] + ']');
}
if (v) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/div[1]/input', v);
}
}
switchNode.prototype.ruleEqual = function (v, vt, index) {
index = index || 1;
setT('eq', index);
setV(v, vt, index);
}
switchNode.prototype.ruleNotEqual = function (v, vt, index) {
index = index || 1;
setT('neq', index);
setV(v, vt, index);
}
switchNode.prototype.ruleLessThan = function (v, vt, index) {
index = index || 1;
setT('lt', index);
setV(v, vt, index);
}
switchNode.prototype.ruleLessThanOrEqual = function (v, vt, index) {
index = index || 1;
setT('lte', index);
setV(v, vt, index);
}
switchNode.prototype.ruleGreaterThan = function (v, vt, index) {
index = index || 1;
setT('gt', index);
setV(v, vt, index);
}
switchNode.prototype.ruleGreaterThanOrEqual = function (v, vt, index) {
index = index || 1;
setT('gte', index);
setV(v, vt, index);
}
switchNode.prototype.ruleHasKey = function (v, vt, index) {
index = index || 1;
setT('hask', index);
setV(v, vt, index);
}
switchNode.prototype.ruleIsBetween = function (v, vt, v2, v2t, index) {
index = index || 1;
setT('btwn', index);
setBetweenV(v, vt, v2, v2t, index);
}
switchNode.prototype.ruleContains = function (v, vt, index) {
index = index || 1;
setT('cont', index);
setV(v, vt, index);
}
switchNode.prototype.ruleMatchesRegex = function (v, vt, index) {
index = index || 1;
setT('regex', index);
setV(v, vt, index);
}
switchNode.prototype.ruleIsTrue = function (index) {
index = index || 1;
setT('true', index);
}
switchNode.prototype.ruleIsFalse = function (index) {
index = index || 1;
setT('false', index);
}
switchNode.prototype.ruleIsNull = function (index) {
index = index || 1;
setT('null', index);
}
switchNode.prototype.ruleIsNotNull = function (index) {
index = index || 1;
setT('nnull', index);
}
switchNode.prototype.ruleIsOfType = function (t, index) {
index = index || 1;
setT('istype', index);
var tType = {
"str": 1,
"num": 2,
"boolean": 3,
"array": 4,
"buffer": 5,
"object": 6,
"json": 7,
"undefined": 8,
"null": 9
};
if (t) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + tType[t] + ']');
}
}
switchNode.prototype.ruleIsEmpty = function (index) {
index = index || 1;
setT('empty', index);
}
switchNode.prototype.ruleIsNotEmpty = function (index) {
index = index || 1;
setT('nempty', index);
}
switchNode.prototype.ruleHead = function (v, vt, index) {
index = index || 1;
setT('head', index);
setSequenceV(v, vt, index);
}
switchNode.prototype.ruleIndexBetween = function (v, vt, v2, v2t, index) {
index = index || 1;
setT('index', index);
setBetweenV(v, vt, v2, v2t, index);
}
switchNode.prototype.ruleTail = function (v, vt, index) {
index = index || 1;
setT('tail', index);
setSequenceV(v, vt, index);
}
switchNode.prototype.ruleJSONataExp = function (v, index) {
index = index || 1;
setT('jsonata_exp', index);
if (v) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/div[1]/input', v);
}
}
switchNode.prototype.ruleOtherwise = function (index) {
index = index || 1;
setT('else', index);
}
switchNode.prototype.addRule = function () {
browser.clickWithWait('//div[contains(@class, "red-ui-editableList")]/a');
}
module.exports = switchNode;

View File

@@ -51,37 +51,78 @@ 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 || 1;
setT("set", index);
setT('set', index);
if (pt) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]');
var num = 5 * (index - 1) + 1;
var ptXPath = '//div[contains(@class, "red-ui-typedInput-options")][' + num + ']/a[' + ptType[pt] + ']';
browser.clickWithWait(ptXPath);
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + ptType[pt] + ']');
}
if (p) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', p);
}
if (tot) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[2]/div[2]/button[1]');
var num = 5 * (index - 1) + 2;
var totXPath = '//div[contains(@class, "red-ui-typedInput-options")][' + num + ']/a[' + totType[tot] + ']';
browser.clickWithWait(totXPath);
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + totType[tot] + ']');
}
if (to) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[2]/div[2]/div/input', to);
}
}
changeNode.prototype.ruleDelete = function (index) {
changeNode.prototype.ruleChange = function (p, pt, from, fromt, to, tot, index) {
index = index || 1;
setT("delete", index);
setT('change', index);
if (pt) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + ptType[pt] + ']');
}
if (p) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', p);
}
if (fromt) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div[1]/div[2]/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + totType[pt] + ']');
}
if (from) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div[1]/div[2]/div[1]/input', from);
}
if (tot) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div[2]/div[2]/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + totType[pt] + ']');
}
if (to) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div[2]/div[2]/div[1]/input', to);
}
}
changeNode.prototype.ruleMove = function (p, to, index) {
changeNode.prototype.ruleDelete = function (p, pt, 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);
setT('delete', index);
if (pt) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + ptType[pt] + ']');
}
if (p) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', p);
}
}
changeNode.prototype.ruleMove = function (p, pt, to, tot, index) {
index = index || 1;
setT('move', index);
if (pt) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + ptType[pt] + ']');
}
if (p) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', p);
}
if (tot) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[4]/div[2]/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + totType[pt] + ']');
}
if (to) {
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[4]/div[2]/div/input', to);
}
}
changeNode.prototype.addRule = function () {

View File

@@ -18,8 +18,6 @@ var util = require("util");
var nodePage = require("../../node_page");
var keyPage = require("../../../util/key_page");
function delayNode(id) {
nodePage.call(this, id);
}

View File

@@ -0,0 +1,83 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
var util = require("util");
var nodePage = require("../../node_page");
function triggerNode(id) {
nodePage.call(this, id);
}
util.inherits(triggerNode, nodePage);
triggerNode.prototype.setSend = function (send, sendt) {
var sendType = {
"flow": 1,
"global": 2,
"str": 3,
"num": 4,
"bool": 5,
"json": 6,
"bin": 7,
"date": 8,
"env": 9,
"pay": 10,
"nul": 11
};
if (sendt) {
browser.clickWithWait('//*[@id="dialog-form"]/div[1]/div/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + sendType[sendt] + ']');
}
if (send) {
browser.setValue('//*[@id="dialog-form"]/div[1]/div/div[1]/input', send);
}
}
triggerNode.prototype.setDuration = function (duration, units) {
browser.setValue('//*[@id="node-input-duration"]', duration);
if (units) {
browser.selectWithWait('//*[@id="node-input-units"]', units);
}
}
triggerNode.prototype.setThenSend = function (thenSend, thenSendt) {
var thenSendType = {
"flow": 1,
"global": 2,
"str": 3,
"num": 4,
"bool": 5,
"json": 6,
"bin": 7,
"date": 8,
"env": 9,
"pay": 10,
"payl": 11,
"nul": 12
};
if (thenSendt) {
browser.clickWithWait('//*[@id="dialog-form"]/div[5]/div/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + thenSendType[thenSendt] + ']');
}
if (thenSend) {
browser.setValue('//*[@id="dialog-form"]/div[5]/div/div[1]/input', thenSend);
}
}
module.exports = triggerNode;

View File

@@ -18,18 +18,20 @@ var util = require("util");
var nodePage = require("../../node_page");
function mqttInNode(id) {
function execNode(id) {
nodePage.call(this, id);
}
util.inherits(mqttInNode, nodePage);
util.inherits(execNode, nodePage);
mqttInNode.prototype.setTopic = function (topic) {
browser.setValue('#node-input-topic', topic);
execNode.prototype.setCommand = function (command) {
browser.setValue('//*[@id="node-input-command"]', command);
}
mqttInNode.prototype.setQoS = function (qos) {
browser.selectWithWait('#node-input-qos', qos);
execNode.prototype.setAppend = function (checkbox) {
if (browser.isSelected('#node-input-addpay') !== checkbox) {
browser.click('#node-input-addpay');
}
}
module.exports = mqttInNode;
module.exports = execNode;

View File

@@ -14,27 +14,61 @@
* limitations under the License.
**/
function setServer(broker, port) {
var util = require("util");
var nodePage = require("../../node_page");
var mqttBrokerNode = {};
mqttBrokerNode.setServer = function (broker, port) {
browser.setValue('#node-config-input-broker', broker);
port = port ? port : 1883;
browser.setValue('#node-config-input-port', port);
}
};
function clickOk() {
mqttBrokerNode.clickOk = function () {
browser.clickWithWait('#node-config-dialog-ok');
// Wait until an config dialog closes.
browser.waitForVisible('#node-config-dialog-ok', 10000, true);
}
};
function edit() {
mqttBrokerNode.edit = function () {
browser.waitForVisible('#node-input-lookup-broker');
browser.click('#node-input-lookup-broker');
// Wait until a config dialog opens.
browser.waitForVisible('#node-config-dialog-ok', 10000);
};
function mqttInNode(id) {
nodePage.call(this, id);
}
module.exports = {
setServer: setServer,
clickOk: clickOk,
edit: edit
util.inherits(mqttInNode, nodePage);
mqttInNode.prototype.setTopic = function (topic) {
browser.setValue('#node-input-topic', topic);
};
mqttInNode.prototype.setQoS = function (qos) {
browser.selectWithWait('#node-input-qos', qos);
};
mqttInNode.prototype.mqttBrokerNode = mqttBrokerNode;
module.exports.mqttInNode = mqttInNode;
function mqttOutNode(id) {
nodePage.call(this, id);
}
util.inherits(mqttOutNode, nodePage);
mqttOutNode.prototype.setTopic = function (topic) {
browser.setValue('#node-input-topic', topic);
};
mqttOutNode.prototype.setRetain = function (retain) {
browser.selectWithWait('#node-input-retain', retain);
};
mqttOutNode.prototype.mqttBrokerNode = mqttBrokerNode;
module.exports.mqttOutNode = mqttOutNode;

View File

@@ -1,35 +0,0 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
var util = require("util");
var nodePage = require("../../node_page");
function mqttOutNode(id) {
nodePage.call(this, id);
}
util.inherits(mqttOutNode, nodePage);
mqttOutNode.prototype.setTopic = function(topic) {
browser.setValue('#node-input-topic', topic);
}
mqttOutNode.prototype.setRetain = function (retain) {
browser.selectWithWait('#node-input-retain', retain);
}
module.exports = mqttOutNode;

View File

@@ -0,0 +1,93 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
var util = require("util");
var nodePage = require("../../node_page");
var websocketListenerNode = {};
websocketListenerNode.setPath = function (path) {
browser.setValue('#node-config-input-path', path);
};
websocketListenerNode.setSendReceive = function (wholemsg) {
browser.selectWithWait('#node-config-input-wholemsg', wholemsg);
};
websocketListenerNode.clickOk = function () {
browser.clickWithWait('#node-config-dialog-ok');
// Wait until an config dialog closes.
browser.waitForVisible('#node-config-dialog-ok', 10000, true);
};
websocketListenerNode.edit = function () {
browser.waitForVisible('#node-input-lookup-server');
browser.click('#node-input-lookup-server');
// Wait until a config dialog opens.
browser.waitForVisible('#node-config-dialog-ok', 10000);
};
var websocketClientNode = {};
websocketClientNode.setPath = function (path) {
browser.setValue('#node-config-input-path', path);
};
websocketClientNode.setSendReceive = function (wholemsg) {
browser.selectWithWait('#node-config-input-wholemsg', wholemsg);
};
websocketClientNode.clickOk = function () {
browser.clickWithWait('#node-config-dialog-ok');
// Wait until an config dialog closes.
browser.waitForVisible('#node-config-dialog-ok', 10000, true);
};
websocketClientNode.edit = function () {
browser.waitForVisible('#node-input-lookup-client');
browser.click('#node-input-lookup-client');
// Wait until a config dialog opens.
browser.waitForVisible('#node-config-dialog-ok', 10000);
};
function websocketInNode(id) {
nodePage.call(this, id);
}
util.inherits(websocketInNode, nodePage);
websocketInNode.prototype.setType = function (type) {
browser.selectWithWait('#node-input-mode', type);
};
websocketInNode.prototype.websocketListenerNode = websocketListenerNode;
websocketInNode.prototype.websocketClientNode = websocketClientNode;
module.exports.websocketInNode = websocketInNode;
function websocketOutNode(id) {
nodePage.call(this, id);
}
util.inherits(websocketOutNode, nodePage);
websocketOutNode.prototype.setType = function (type) {
browser.selectWithWait('#node-input-mode', type);
};
websocketOutNode.prototype.websocketListenerNode = websocketListenerNode;
websocketOutNode.prototype.websocketClientNode = websocketClientNode;
module.exports.websocketOutNode = websocketOutNode;

View File

@@ -24,7 +24,19 @@ function splitNode(id) {
util.inherits(splitNode, nodePage);
module.exports = splitNode;
splitNode.prototype.setSplitUsing = function (splt, spltt) {
var spltType = {
"str": 1,
"bin": 2,
"len": 3
};
browser.clickWithWait('//*[@id="dialog-form"]/div[3]/div/button[1]');
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + spltType[spltt] + ']');
browser.setValue('//*[@id="dialog-form"]/div[3]/div/div[1]/input', splt);
};
module.exports.splitNode = splitNode;
function joinNode(id) {
nodePage.call(this, id);
@@ -32,4 +44,4 @@ function joinNode(id) {
util.inherits(joinNode, nodePage);
module.exports = joinNode;
module.exports.joinNode = joinNode;