topological-nodered-wdio 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,50 +1,50 @@
1
- const common = require('./wdio-common')
2
-
3
- module.exports = function(RED) {
4
- function dropdownAction(config) {
5
- RED.nodes.createNode(this, config)
6
- const node = this
7
- common.clearStatus(node)
8
-
9
- node.on('input', async (msg) => {
10
- try {
11
- let locateUsing = config.locateUsing || msg.locateUsing
12
- let locateValue = config.locateValue || msg.locateValue
13
-
14
- let browser = await common.getBrowser(node.context())
15
- let locator = await common.getLocator(
16
- browser,
17
- locateUsing,
18
- locateValue
19
- )
20
- let element = await browser.$(locator)
21
-
22
- let text = config.text || msg.text
23
- let attribute = config.attribute || msg.attribute
24
- let index = config.index || msg.index
25
- let value = config.value || msg.value
26
-
27
- if (config.action === 'selectByAttr') {
28
- node.log = `Select the dropdown value using Attribute: ${attribute} with Value: ${value}.`
29
- await element.selectByAttribute(attribute, value)
30
- } else if (config.action === 'selectByIndex') {
31
- node.log = `Select the dropdown value using Index: ${index}.`
32
- await element.selectByIndex(parseInt(index))
33
- } else if (config.action === 'selectByText') {
34
- node.log = `Select the dropdown value using Visible text: ${text}.`
35
- await element.selectByVisibleText(text)
36
- } else if (config.action === 'getValue') {
37
- node.log = 'Get selected drop down value.'
38
- msg.payload = await element.getValue()
39
- }
40
- await common.log(node)
41
- common.successStatus(node)
42
- node.send(msg)
43
- } catch (e) {
44
- await common.log(node)
45
- common.handleError(e, node, msg)
46
- }
47
- })
48
- }
49
- RED.nodes.registerType('dropdown-action', dropdownAction)
50
- }
1
+ const common = require('./wdio-common')
2
+
3
+ module.exports = function(RED) {
4
+ function dropdownAction(config) {
5
+ RED.nodes.createNode(this, config)
6
+ const node = this
7
+ common.clearStatus(node)
8
+
9
+ node.on('input', async (msg) => {
10
+ try {
11
+ let locateUsing = config.locateUsing || msg.locateUsing
12
+ let locateValue = config.locateValue || msg.locateValue
13
+
14
+ let browser = await common.getBrowser(node.context())
15
+ let locator = await common.getLocator(
16
+ browser,
17
+ locateUsing,
18
+ locateValue
19
+ )
20
+ let element = await browser.$(locator)
21
+
22
+ let text = config.text || msg.text
23
+ let attribute = config.attribute || msg.attribute
24
+ let index = config.index || msg.index
25
+ let value = config.value || msg.value
26
+
27
+ if (config.action === 'selectByAttr') {
28
+ node.log = `Select the dropdown value using Attribute: ${attribute} with Value: ${value}.`
29
+ await element.selectByAttribute(attribute, value)
30
+ } else if (config.action === 'selectByIndex') {
31
+ node.log = `Select the dropdown value using Index: ${index}.`
32
+ await element.selectByIndex(parseInt(index))
33
+ } else if (config.action === 'selectByText') {
34
+ node.log = `Select the dropdown value using Visible text: ${text}.`
35
+ await element.selectByVisibleText(text)
36
+ } else if (config.action === 'getValue') {
37
+ node.log = 'Get selected drop down value.'
38
+ msg.payload = await element.getValue()
39
+ }
40
+ await common.log(node)
41
+ common.successStatus(node)
42
+ node.send(msg)
43
+ } catch (e) {
44
+ await common.log(node)
45
+ common.handleError(e, node, msg)
46
+ }
47
+ })
48
+ }
49
+ RED.nodes.registerType('dropdown-action', dropdownAction)
50
+ }
@@ -1,133 +1,133 @@
1
- <script type="text/javascript">
2
- function setAction() {
3
- let action = $('#node-input-action').val()
4
- $('#actionSendKeys').hide()
5
- $('#getAttribute').hide()
6
- if (action == 'sendKeys') {
7
- $('#actionSendKeys').show()
8
- }
9
- if (action == 'getAttribute') {
10
- $('#getAttribute').show()
11
- }
12
- }
13
-
14
- RED.nodes.registerType('element-action', {
15
- category: 'Webdriver IO',
16
- color: '#a6bbcf',
17
- defaults: {
18
- name: { value: '' },
19
- locateUsing: { value: 'xpath' },
20
- locateValue: { value: '' },
21
- action: { value: 'click' },
22
- sendKeys: {
23
- value: '',
24
- validate: RED.validators.typedInput('object')
25
- },
26
- object: { value: '' },
27
- attribute: { value: '' }
28
- },
29
- inputs: 1,
30
- outputs: 1,
31
- icon: 'white-globe.png',
32
- label: function() {
33
- return this.name || 'element action'
34
- },
35
- oneditprepare: function() {
36
- setAction()
37
- $('#node-input-sendKeys').typedInput({
38
- default: 'str',
39
- typeField: $('#node-input-object'),
40
- types: ['msg', 'flow', 'global', 'str']
41
- })
42
- }
43
- })
44
- </script>
45
-
46
- <script type="text/x-red" data-template-name="element-action">
47
- <div class="form-row">
48
- <label for="node-input-locateUsing"><i class="fa fa-tasks"></i> Locate Method</label>
49
- <select type="text" id="node-input-locateUsing" style="width:70%;">
50
- <option value="id">id</option>
51
- <option value="name">name</option>
52
- <option value="css selector">CSS selector</option>
53
- <option value="link text">Link text</option>
54
- <option value="partial link text">Partial link text</option>
55
- <option value="tag name">Tag name</option>
56
- <option value="xpath" selected>XPath</option>
57
- </select>
58
- </div>
59
- <div class="form-row">
60
- <label for="node-input-locateValue"><i class="fa fa-tasks"></i> Selector</label>
61
- <input id="node-input-locateValue" type="text">
62
- </div>
63
-
64
- <div class="form-row">
65
- <label for="node-input-action"><i class="fa fa-tasks"></i> Action</label>
66
- <select type="text" id="node-input-action" style="width:70%;" onchange="setAction()">
67
- <option value="click">Click</option>
68
- <option value="clear">Clear</option>
69
- <option value="sendKeys">Send Keys</option>
70
- <option value="getValue">Get Value</option>
71
- <option value="getText">Get Text</option>
72
- <option value="getAttribute">Get Attribute</option>
73
- <option value="takeScreenShot">Element Screenshot</option>
74
- <option value="hover">Hover</option>
75
- </select>
76
- </div>
77
- <div class="form-row" id="actionSendKeys">
78
- <label for="node-input-sendKeys"><i class="fa fa-tasks"></i> Text to Send</label>
79
- <input type="text" id="node-input-sendKeys" style="width:70%">
80
- <input type="hidden" id="node-input-object">
81
- </div>
82
- <div class="form-row" id="getAttribute">
83
- <label for="node-input-attribute"><i class="fa fa-tasks"></i>Attribute Name</label>
84
- <input id="node-input-attribute" type="text">
85
- </div>
86
- <div class="form-row">
87
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
88
- <input id="node-input-name" type="text">
89
- </div>
90
- </script>
91
-
92
- <script type="text/x-red" data-help-name="element-action">
93
- <h3>Perform a list of actions on a target web element.</h3>
94
- <h3>Inputs</h3>
95
- <dl class="message-properties">
96
-
97
- <dt><code>mgs.locateUsing</code>: <span class="property-type">string</span></dt>
98
- <dd>specifies the type of web element identifier:
99
- <ul>
100
- <li>id</li>
101
- <li>name</li>
102
- <li>CSS selector</li>
103
- <li>Link text</li>
104
- <li>Partial link text</li>
105
- <li>Tag name</li>
106
- <li>XPath</li>
107
- </ul>
108
- <br>
109
- </dd>
110
- <dt><code>msg.locateValue</code><span class="property-type">string</span></dt>
111
- <dd>value passed to the web element identifier (Locate Method)<br></dd>
112
-
113
- <dt><code>msg.value</code><span class="property-type">string</span></dt>
114
- <dd>If you elect to SendKeys to the web element, this is the value that would be sent</dd>
115
- </dl>
116
-
117
- <h3>Details</h3>
118
- <p><b>Locate Method</b> specifies the method used to target the web element. This option can be selected manually from the Properties panel OR it can be received from <code>mgs.locateUsing</code><br></p>
119
- <p><b>Selector</b> value used by the Locate Method to target the web element. This option can be selected manually from the Properties panel OR it can be received from <code>mgs.locateValue</code><br></p>
120
- <p><b>Action</b> specifies the action to be performed on the target web element. Actions includes:
121
- <ul>
122
- <li>Click</li>
123
- <li>Clear</li>
124
- <li>Send Keys</li>
125
- <li>Get Value</li>
126
- <li>Get Text</li>
127
- <li>Get Attribute</li>
128
- <li>Element Screenshot</li>
129
- <li>Hover</li>
130
- </ul>
131
- </p>
132
- <p><b>Text to Send</b> if the Send Keys action is selected, this value would send the text to the selected web element.<br></p>
133
- </script>
1
+ <script type="text/javascript">
2
+ function setAction() {
3
+ let action = $('#node-input-action').val()
4
+ $('#actionSendKeys').hide()
5
+ $('#getAttribute').hide()
6
+ if (action == 'sendKeys') {
7
+ $('#actionSendKeys').show()
8
+ }
9
+ if (action == 'getAttribute') {
10
+ $('#getAttribute').show()
11
+ }
12
+ }
13
+
14
+ RED.nodes.registerType('element-action', {
15
+ category: 'Webdriver IO',
16
+ color: '#a6bbcf',
17
+ defaults: {
18
+ name: { value: '' },
19
+ locateUsing: { value: 'xpath' },
20
+ locateValue: { value: '' },
21
+ action: { value: 'click' },
22
+ sendKeys: {
23
+ value: '',
24
+ validate: RED.validators.typedInput('object')
25
+ },
26
+ object: { value: '' },
27
+ attribute: { value: '' }
28
+ },
29
+ inputs: 1,
30
+ outputs: 1,
31
+ icon: 'white-globe.png',
32
+ label: function() {
33
+ return this.name || 'element action'
34
+ },
35
+ oneditprepare: function() {
36
+ setAction()
37
+ $('#node-input-sendKeys').typedInput({
38
+ default: 'str',
39
+ typeField: $('#node-input-object'),
40
+ types: ['msg', 'flow', 'global', 'str']
41
+ })
42
+ }
43
+ })
44
+ </script>
45
+
46
+ <script type="text/x-red" data-template-name="element-action">
47
+ <div class="form-row">
48
+ <label for="node-input-locateUsing"><i class="fa fa-tasks"></i> Locate Method</label>
49
+ <select type="text" id="node-input-locateUsing" style="width:70%;">
50
+ <option value="id">id</option>
51
+ <option value="name">name</option>
52
+ <option value="css selector">CSS selector</option>
53
+ <option value="link text">Link text</option>
54
+ <option value="partial link text">Partial link text</option>
55
+ <option value="tag name">Tag name</option>
56
+ <option value="xpath" selected>XPath</option>
57
+ </select>
58
+ </div>
59
+ <div class="form-row">
60
+ <label for="node-input-locateValue"><i class="fa fa-tasks"></i> Selector</label>
61
+ <input id="node-input-locateValue" type="text">
62
+ </div>
63
+
64
+ <div class="form-row">
65
+ <label for="node-input-action"><i class="fa fa-tasks"></i> Action</label>
66
+ <select type="text" id="node-input-action" style="width:70%;" onchange="setAction()">
67
+ <option value="click">Click</option>
68
+ <option value="clear">Clear</option>
69
+ <option value="sendKeys">Send Keys</option>
70
+ <option value="getValue">Get Value</option>
71
+ <option value="getText">Get Text</option>
72
+ <option value="getAttribute">Get Attribute</option>
73
+ <option value="takeScreenShot">Element Screenshot</option>
74
+ <option value="hover">Hover</option>
75
+ </select>
76
+ </div>
77
+ <div class="form-row" id="actionSendKeys">
78
+ <label for="node-input-sendKeys"><i class="fa fa-tasks"></i> Text to Send</label>
79
+ <input type="text" id="node-input-sendKeys" style="width:70%">
80
+ <input type="hidden" id="node-input-object">
81
+ </div>
82
+ <div class="form-row" id="getAttribute">
83
+ <label for="node-input-attribute"><i class="fa fa-tasks"></i>Attribute Name</label>
84
+ <input id="node-input-attribute" type="text">
85
+ </div>
86
+ <div class="form-row">
87
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
88
+ <input id="node-input-name" type="text">
89
+ </div>
90
+ </script>
91
+
92
+ <script type="text/x-red" data-help-name="element-action">
93
+ <h3>Perform a list of actions on a target web element.</h3>
94
+ <h3>Inputs</h3>
95
+ <dl class="message-properties">
96
+
97
+ <dt><code>mgs.locateUsing</code>: <span class="property-type">string</span></dt>
98
+ <dd>specifies the type of web element identifier:
99
+ <ul>
100
+ <li>id</li>
101
+ <li>name</li>
102
+ <li>CSS selector</li>
103
+ <li>Link text</li>
104
+ <li>Partial link text</li>
105
+ <li>Tag name</li>
106
+ <li>XPath</li>
107
+ </ul>
108
+ <br>
109
+ </dd>
110
+ <dt><code>msg.locateValue</code><span class="property-type">string</span></dt>
111
+ <dd>value passed to the web element identifier (Locate Method)<br></dd>
112
+
113
+ <dt><code>msg.value</code><span class="property-type">string</span></dt>
114
+ <dd>If you elect to SendKeys to the web element, this is the value that would be sent</dd>
115
+ </dl>
116
+
117
+ <h3>Details</h3>
118
+ <p><b>Locate Method</b> specifies the method used to target the web element. This option can be selected manually from the Properties panel OR it can be received from <code>mgs.locateUsing</code><br></p>
119
+ <p><b>Selector</b> value used by the Locate Method to target the web element. This option can be selected manually from the Properties panel OR it can be received from <code>mgs.locateValue</code><br></p>
120
+ <p><b>Action</b> specifies the action to be performed on the target web element. Actions includes:
121
+ <ul>
122
+ <li>Click</li>
123
+ <li>Clear</li>
124
+ <li>Send Keys</li>
125
+ <li>Get Value</li>
126
+ <li>Get Text</li>
127
+ <li>Get Attribute</li>
128
+ <li>Element Screenshot</li>
129
+ <li>Hover</li>
130
+ </ul>
131
+ </p>
132
+ <p><b>Text to Send</b> if the Send Keys action is selected, this value would send the text to the selected web element.<br></p>
133
+ </script>
@@ -1,105 +1,105 @@
1
- const common = require('./wdio-common')
2
-
3
- module.exports = function(RED) {
4
- function elementAction(config) {
5
- RED.nodes.createNode(this, config)
6
- const node = this
7
- const context = node.context()
8
- common.clearStatus(node)
9
-
10
- var getTypeInputValue = async (msg, type, value) => {
11
- var r = ''
12
- switch (type) {
13
- case 'msg':
14
- r = RED.util.getMessageProperty(msg, value)
15
- break
16
- case 'flow':
17
- r = context.flow.get(value)
18
- break
19
- case 'global':
20
- r = context.global.get(value)
21
- break
22
- case 'str':
23
- try {
24
- r = unescape(JSON.parse('"' + value + '"'))
25
- } catch (e) {
26
- r = value
27
- }
28
- break
29
- case 'num':
30
- r = parseFloat(value)
31
- break
32
- case 'json':
33
- if (value !== '') {
34
- r = JSON.parse(value)
35
- } else {
36
- r = undefined
37
- }
38
- }
39
- return r
40
- }
41
-
42
- node.on('input', async (msg) => {
43
- try {
44
- let locateUsing = config.locateUsing || msg.locateUsing
45
- let locateValue = config.locateValue || msg.locateValue
46
-
47
- let browser = await common.getBrowser(context)
48
- let capabilities = browser.capabilities
49
- let elementId = await common.getElementId(
50
- browser,
51
- locateUsing,
52
- locateValue
53
- )
54
-
55
- let attribute = config.attribute || msg.attribute
56
-
57
- if (config.action === 'click') {
58
- node.log = `Click on the webelement identified using ${locateUsing}: "${locateValue}".`
59
- await browser.elementClick(elementId)
60
- } else if (config.action === 'clear') {
61
- node.log = `Clear the Value of the webelement identified using ${locateUsing}: "${locateValue}".`
62
- await browser.elementClear(elementId)
63
- } else if (config.action === 'sendKeys') {
64
- let value = await getTypeInputValue(
65
- msg,
66
- config.object,
67
- config.sendKeys
68
- )
69
- node.log = `Enter the Value: "${value}" to the webelement identified using ${locateUsing}: "${locateValue}".`
70
- await browser.elementSendKeys(
71
- elementId,
72
- capabilities.version ? Array.from(value) : value
73
- )
74
- } else if (config.action === 'getValue') {
75
- node.log = `Get the Value of webelement identified using ${locateUsing}: "${locateValue}".`
76
- msg.payload = await browser.getElementAttribute(elementId, 'value')
77
- } else if (config.action === 'getText') {
78
- node.log = `Get the Text of webelement identified using ${locateUsing}: "${locateValue}".`
79
- msg.payload = await browser.getElementText(elementId)
80
- } else if (config.action === 'getAttribute') {
81
- node.log = `Get the Attribute: "${attribute}" of webelement identified using ${locateUsing}: "${locateValue}".`
82
- msg.payload = await browser.getElementAttribute(elementId, attribute)
83
- } else if (config.action === 'takeScreenShot') {
84
- node.log = 'Take the screenshot of the webelement.'
85
- msg.payload = await browser.takeElementScreenshot(elementId)
86
- } else if (config.action === 'hover') {
87
- let element = await common.getElement(
88
- browser,
89
- locateUsing,
90
- locateValue
91
- )
92
- node.log = `Hover on the webelement identified using ${locateUsing}: "${locateValue}".`
93
- msg.payload = await element.moveTo()
94
- }
95
- await common.log(node)
96
- common.successStatus(node)
97
- node.send(msg)
98
- } catch (e) {
99
- await common.log(node)
100
- common.handleError(e, node, msg)
101
- }
102
- })
103
- }
104
- RED.nodes.registerType('element-action', elementAction)
105
- }
1
+ const common = require('./wdio-common')
2
+
3
+ module.exports = function(RED) {
4
+ function elementAction(config) {
5
+ RED.nodes.createNode(this, config)
6
+ const node = this
7
+ const context = node.context()
8
+ common.clearStatus(node)
9
+
10
+ var getTypeInputValue = async (msg, type, value) => {
11
+ var r = ''
12
+ switch (type) {
13
+ case 'msg':
14
+ r = RED.util.getMessageProperty(msg, value)
15
+ break
16
+ case 'flow':
17
+ r = context.flow.get(value)
18
+ break
19
+ case 'global':
20
+ r = context.global.get(value)
21
+ break
22
+ case 'str':
23
+ try {
24
+ r = unescape(JSON.parse('"' + value + '"'))
25
+ } catch (e) {
26
+ r = value
27
+ }
28
+ break
29
+ case 'num':
30
+ r = parseFloat(value)
31
+ break
32
+ case 'json':
33
+ if (value !== '') {
34
+ r = JSON.parse(value)
35
+ } else {
36
+ r = undefined
37
+ }
38
+ }
39
+ return r
40
+ }
41
+
42
+ node.on('input', async (msg) => {
43
+ try {
44
+ let locateUsing = config.locateUsing || msg.locateUsing
45
+ let locateValue = config.locateValue || msg.locateValue
46
+
47
+ let browser = await common.getBrowser(context)
48
+ let capabilities = browser.capabilities
49
+ let elementId = await common.getElementId(
50
+ browser,
51
+ locateUsing,
52
+ locateValue
53
+ )
54
+
55
+ let attribute = config.attribute || msg.attribute
56
+
57
+ if (config.action === 'click') {
58
+ node.log = `Click on the webelement identified using ${locateUsing}: "${locateValue}".`
59
+ await browser.elementClick(elementId)
60
+ } else if (config.action === 'clear') {
61
+ node.log = `Clear the Value of the webelement identified using ${locateUsing}: "${locateValue}".`
62
+ await browser.elementClear(elementId)
63
+ } else if (config.action === 'sendKeys') {
64
+ let value = await getTypeInputValue(
65
+ msg,
66
+ config.object,
67
+ config.sendKeys
68
+ )
69
+ node.log = `Enter the Value: "${value}" to the webelement identified using ${locateUsing}: "${locateValue}".`
70
+ await browser.elementSendKeys(
71
+ elementId,
72
+ capabilities.version ? Array.from(value) : value
73
+ )
74
+ } else if (config.action === 'getValue') {
75
+ node.log = `Get the Value of webelement identified using ${locateUsing}: "${locateValue}".`
76
+ msg.payload = await browser.getElementAttribute(elementId, 'value')
77
+ } else if (config.action === 'getText') {
78
+ node.log = `Get the Text of webelement identified using ${locateUsing}: "${locateValue}".`
79
+ msg.payload = await browser.getElementText(elementId)
80
+ } else if (config.action === 'getAttribute') {
81
+ node.log = `Get the Attribute: "${attribute}" of webelement identified using ${locateUsing}: "${locateValue}".`
82
+ msg.payload = await browser.getElementAttribute(elementId, attribute)
83
+ } else if (config.action === 'takeScreenShot') {
84
+ node.log = 'Take the screenshot of the webelement.'
85
+ msg.payload = await browser.takeElementScreenshot(elementId)
86
+ } else if (config.action === 'hover') {
87
+ let element = await common.getElement(
88
+ browser,
89
+ locateUsing,
90
+ locateValue
91
+ )
92
+ node.log = `Hover on the webelement identified using ${locateUsing}: "${locateValue}".`
93
+ msg.payload = await element.moveTo()
94
+ }
95
+ await common.log(node)
96
+ common.successStatus(node)
97
+ node.send(msg)
98
+ } catch (e) {
99
+ await common.log(node)
100
+ common.handleError(e, node, msg)
101
+ }
102
+ })
103
+ }
104
+ RED.nodes.registerType('element-action', elementAction)
105
+ }