2018-01-17 10:50:46 +01:00
|
|
|
/**
|
|
|
|
* 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 injectNode(id) {
|
|
|
|
nodePage.call(this, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
util.inherits(injectNode, nodePage);
|
|
|
|
|
2018-08-22 07:36:30 +02:00
|
|
|
var payloadTypeList = {
|
2018-01-17 10:50:46 +01:00
|
|
|
"flow": 1,
|
|
|
|
"global": 2,
|
2018-07-19 06:17:41 +02:00
|
|
|
"str": 3,
|
2018-01-17 10:50:46 +01:00
|
|
|
"num": 4,
|
|
|
|
"bool": 5,
|
|
|
|
"json": 6,
|
|
|
|
"bin": 7,
|
|
|
|
"date": 8,
|
2018-06-29 03:41:44 +02:00
|
|
|
"env": 9,
|
2018-01-17 10:50:46 +01:00
|
|
|
};
|
|
|
|
|
2018-08-22 07:36:30 +02:00
|
|
|
var repeatTypeList = {
|
2018-07-19 06:17:41 +02:00
|
|
|
"none": 1,
|
|
|
|
"interval": 2,
|
|
|
|
"intervalBetweenTimes": 3,
|
|
|
|
"atASpecificTime": 4,
|
|
|
|
};
|
|
|
|
|
2018-08-22 07:36:30 +02:00
|
|
|
injectNode.prototype.setPayload = function(payloadType, payload) {
|
2018-01-17 10:50:46 +01:00
|
|
|
// Open a payload type list.
|
|
|
|
browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-container")]');
|
|
|
|
// Select a payload type.
|
2019-12-02 04:43:13 +01:00
|
|
|
var payloadTypeXPath = '//*[contains(@class, "red-ui-typedInput-options")]/a[' + payloadTypeList[payloadType] + ']';
|
2018-01-17 10:50:46 +01:00
|
|
|
browser.clickWithWait(payloadTypeXPath);
|
2018-08-22 07:36:30 +02:00
|
|
|
if (payload) {
|
2018-07-27 06:48:43 +02:00
|
|
|
// Input a value.
|
2019-12-02 04:43:13 +01:00
|
|
|
browser.setValue('//*[contains(@class, "red-ui-typedInput-input")]/input', payload);
|
2018-07-27 06:48:43 +02:00
|
|
|
}
|
2018-01-17 10:50:46 +01:00
|
|
|
}
|
|
|
|
|
2018-08-22 07:36:30 +02:00
|
|
|
injectNode.prototype.setTopic = function(topic) {
|
|
|
|
browser.setValue('#node-input-topic', topic);
|
2018-01-17 10:50:46 +01:00
|
|
|
}
|
|
|
|
|
2018-08-22 07:36:30 +02:00
|
|
|
injectNode.prototype.setOnce = function(once) {
|
|
|
|
var isChecked = browser.isSelected('#node-input-once');
|
|
|
|
if (isChecked !== once) {
|
|
|
|
browser.clickWithWait('#node-input-once');
|
|
|
|
}
|
2018-07-12 08:28:40 +02:00
|
|
|
}
|
|
|
|
|
2018-08-22 07:36:30 +02:00
|
|
|
injectNode.prototype.setRepeat = function(repeatType) {
|
|
|
|
var repeatTypeXPath = '//*[@id="inject-time-type-select"]/option[' + repeatTypeList[repeatType] + ']';
|
|
|
|
browser.clickWithWait(repeatTypeXPath);
|
2018-07-12 08:28:40 +02:00
|
|
|
}
|
|
|
|
|
2018-08-22 07:36:30 +02:00
|
|
|
injectNode.prototype.setRepeatInterval = function(repeat) {
|
|
|
|
browser.setValue('#inject-time-interval-count', repeat);
|
2018-07-12 08:28:40 +02:00
|
|
|
}
|
|
|
|
|
2018-01-17 10:50:46 +01:00
|
|
|
module.exports = injectNode;
|