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,70 +1,70 @@
1
- const common = require('./wdio-common')
2
-
3
- module.exports = function(RED) {
4
- function browserAction(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 browser = await common.getBrowser(node.context())
12
-
13
- let url = config.url || msg.url
14
- let height = config.height || msg.height
15
- let width = config.width || msg.width
16
- let keys = config.keysArr || msg.keysArr
17
-
18
- if (config.action === 'getUrl') {
19
- node.log = 'Get the url of the web page.'
20
- msg.payload = await browser.getUrl()
21
- } else if (config.action === 'navigateTo') {
22
- node.log = `Navigate to url: "${url}".`
23
- await browser.navigateTo(url)
24
- } else if (config.action === 'back') {
25
- node.log = 'Go to previous page (browser back feature).'
26
- await browser.back()
27
- } else if (config.action === 'forward') {
28
- node.log = 'Go for next page (browser forward feature).'
29
- await browser.forward()
30
- } else if (config.action === 'refresh') {
31
- node.log = 'Refresh the web page.'
32
- await browser.refresh()
33
- } else if (config.action === 'getTitle') {
34
- node.log = 'Get the title of the browser window.'
35
- msg.payload = await browser.getTitle()
36
- } else if (config.action === 'setSize') {
37
- node.log = `Set the Size of browser window to Width: ${width}, Height: ${height}.`
38
- await browser.setWindowSize(parseInt(width), parseInt(height))
39
- } else if (config.action === 'maximize') {
40
- node.log = 'Maximize the browser window.'
41
- await browser.maximizeWindow()
42
- } else if (config.action === 'takeScreenShot') {
43
- node.log = 'Take the screenshot of the browser window.'
44
- msg.payload = await browser.takeScreenshot()
45
- } else if (config.action === 'pageSource') {
46
- node.log = 'Get the Page sorce (Source code of the web page).'
47
- msg.payload = await browser.getPageSource()
48
- } else if (config.action === 'getCookies') {
49
- node.log = 'Get the cookies stored.'
50
- msg.payload = await browser.getAllCookies()
51
- } else if (config.action === 'print') {
52
- node.log = 'Print the page.'
53
- await browser.execute('setTimeout(()=> {window.print()}, 2000)')
54
- } else if (config.action === 'keyStrokes') {
55
- node.log = `Enter the provide keystrokes: ${key}.`
56
- let arr = keys.split(',')
57
- let keyValues = arr.map((item) => item.trim())
58
- await browser.keys(Array.from(keyValues))
59
- }
60
- await common.log(node)
61
- common.successStatus(node)
62
- node.send(msg)
63
- } catch (e) {
64
- await common.log(node)
65
- common.handleError(e, node, msg)
66
- }
67
- })
68
- }
69
- RED.nodes.registerType('browser-action', browserAction)
70
- }
1
+ const common = require('./wdio-common')
2
+
3
+ module.exports = function(RED) {
4
+ function browserAction(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 browser = await common.getBrowser(node.context())
12
+
13
+ let url = config.url || msg.url
14
+ let height = config.height || msg.height
15
+ let width = config.width || msg.width
16
+ let keys = config.keysArr || msg.keysArr
17
+
18
+ if (config.action === 'getUrl') {
19
+ node.log = 'Get the url of the web page.'
20
+ msg.payload = await browser.getUrl()
21
+ } else if (config.action === 'navigateTo') {
22
+ node.log = `Navigate to url: "${url}".`
23
+ await browser.navigateTo(url)
24
+ } else if (config.action === 'back') {
25
+ node.log = 'Go to previous page (browser back feature).'
26
+ await browser.back()
27
+ } else if (config.action === 'forward') {
28
+ node.log = 'Go for next page (browser forward feature).'
29
+ await browser.forward()
30
+ } else if (config.action === 'refresh') {
31
+ node.log = 'Refresh the web page.'
32
+ await browser.refresh()
33
+ } else if (config.action === 'getTitle') {
34
+ node.log = 'Get the title of the browser window.'
35
+ msg.payload = await browser.getTitle()
36
+ } else if (config.action === 'setSize') {
37
+ node.log = `Set the Size of browser window to Width: ${width}, Height: ${height}.`
38
+ await browser.setWindowSize(parseInt(width), parseInt(height))
39
+ } else if (config.action === 'maximize') {
40
+ node.log = 'Maximize the browser window.'
41
+ await browser.maximizeWindow()
42
+ } else if (config.action === 'takeScreenShot') {
43
+ node.log = 'Take the screenshot of the browser window.'
44
+ msg.payload = await browser.takeScreenshot()
45
+ } else if (config.action === 'pageSource') {
46
+ node.log = 'Get the Page sorce (Source code of the web page).'
47
+ msg.payload = await browser.getPageSource()
48
+ } else if (config.action === 'getCookies') {
49
+ node.log = 'Get the cookies stored.'
50
+ msg.payload = await browser.getAllCookies()
51
+ } else if (config.action === 'print') {
52
+ node.log = 'Print the page.'
53
+ await browser.execute('setTimeout(()=> {window.print()}, 2000)')
54
+ } else if (config.action === 'keyStrokes') {
55
+ node.log = `Enter the provide keystrokes: ${key}.`
56
+ let arr = keys.split(',')
57
+ let keyValues = arr.map((item) => item.trim())
58
+ await browser.keys(Array.from(keyValues))
59
+ }
60
+ await common.log(node)
61
+ common.successStatus(node)
62
+ node.send(msg)
63
+ } catch (e) {
64
+ await common.log(node)
65
+ common.handleError(e, node, msg)
66
+ }
67
+ })
68
+ }
69
+ RED.nodes.registerType('browser-action', browserAction)
70
+ }
@@ -1,26 +1,26 @@
1
- <script type="text/javascript">
2
- RED.nodes.registerType('delete-session', {
3
- category: 'Webdriver IO',
4
- color: '#a6bbcf',
5
- defaults: {
6
- name: { value: '' }
7
- },
8
- inputs: 1,
9
- outputs: 1,
10
- icon: 'white-globe.png',
11
- label: function() {
12
- return this.name || 'delete session'
13
- }
14
- })
15
- </script>
16
-
17
- <script type="text/x-red" data-template-name="delete-session">
18
- <div class="form-row">
19
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
20
- <input id="node-input-name" type="text">
21
- </div>
22
- </script>
23
-
24
- <script type="text/x-red" data-help-name="delete-session">
25
- <h3><br><br>Deletes the session and also sets the "wdio_browser" global variable to \'\'.</h3>
26
- </script>
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('delete-session', {
3
+ category: 'Webdriver IO',
4
+ color: '#a6bbcf',
5
+ defaults: {
6
+ name: { value: '' }
7
+ },
8
+ inputs: 1,
9
+ outputs: 1,
10
+ icon: 'white-globe.png',
11
+ label: function() {
12
+ return this.name || 'delete session'
13
+ }
14
+ })
15
+ </script>
16
+
17
+ <script type="text/x-red" data-template-name="delete-session">
18
+ <div class="form-row">
19
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
20
+ <input id="node-input-name" type="text">
21
+ </div>
22
+ </script>
23
+
24
+ <script type="text/x-red" data-help-name="delete-session">
25
+ <h3><br><br>Deletes the session and also sets the "wdio_browser" global variable to \'\'.</h3>
26
+ </script>
@@ -1,29 +1,29 @@
1
- const common = require('./wdio-common')
2
-
3
- module.exports = function(RED) {
4
- function deleteSession(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 browser = await common.deleteSession(node.context())
12
- if (browser && browser.sessionId) {
13
- node.log = 'Close the browser.'
14
- msg.payload = browser.sessionId
15
- } else {
16
- node.log = 'No active browser detected to Close.'
17
- msg.payload = 'no open session'
18
- }
19
- await common.log(node)
20
- common.successStatus(node)
21
- node.send(msg)
22
- } catch (e) {
23
- await common.log(node)
24
- common.handleError(e, node, msg)
25
- }
26
- })
27
- }
28
- RED.nodes.registerType('delete-session', deleteSession)
29
- }
1
+ const common = require('./wdio-common')
2
+
3
+ module.exports = function(RED) {
4
+ function deleteSession(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 browser = await common.deleteSession(node.context())
12
+ if (browser && browser.sessionId) {
13
+ node.log = 'Close the browser.'
14
+ msg.payload = browser.sessionId
15
+ } else {
16
+ node.log = 'No active browser detected to Close.'
17
+ msg.payload = 'no open session'
18
+ }
19
+ await common.log(node)
20
+ common.successStatus(node)
21
+ node.send(msg)
22
+ } catch (e) {
23
+ await common.log(node)
24
+ common.handleError(e, node, msg)
25
+ }
26
+ })
27
+ }
28
+ RED.nodes.registerType('delete-session', deleteSession)
29
+ }
@@ -0,0 +1,46 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('document-helper', {
3
+ category: 'Webdriver IO',
4
+ color: '#E2D96E',
5
+ defaults: {
6
+ name: { value: '' },
7
+ desc: { value: '' }
8
+ },
9
+ inputs: 1,
10
+ outputs: 1,
11
+ icon: 'font-awesome/fa-file-text-o',
12
+ label: function() {
13
+ return this.name || 'document-helper'
14
+ }
15
+ })
16
+ </script>
17
+
18
+ <script type="text/x-red" data-template-name="document-helper">
19
+
20
+ <div class="form-row">
21
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
22
+ <input id="node-input-name" type="text">
23
+ </div>
24
+
25
+ <div class="form-row">
26
+ <label for="node-input-desc"><i class="fa fa-tag"></i> Description</label>
27
+ <textarea id="node-input-desc" name="node-input-desc" rows="20" cols="50" style="min-width:70%; "/>
28
+ </div>
29
+ </script>
30
+
31
+
32
+
33
+ <script type="text/x-red" data-help-name="document-helper">
34
+ <h3>Log helper node uses to add notes to <code>global.document</code></h3>
35
+ <h3>Details</h3>
36
+ <dl class="message-properties">
37
+ <dt>Name: name of the log to be added to <code>global.document</code></dt>
38
+ <dt>Description: more details about the node</dt>
39
+ </dl>
40
+
41
+ <h3>Outputs</h3>
42
+ <dl class="message-properties">
43
+ <dt>msg: <span class="property-type">object</span></dt>
44
+ </dl>
45
+
46
+ </script>
@@ -0,0 +1,21 @@
1
+ const common = require('./wdio-common')
2
+
3
+ module.exports = function(RED) {
4
+ function documentHelper(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
+ common.document(node)
12
+ node.send(msg)
13
+ common.successStatus(node)
14
+ } catch (e) {
15
+ await common.log(node)
16
+ common.handleError(e, node, msg)
17
+ }
18
+ })
19
+ }
20
+ RED.nodes.registerType('document-helper', documentHelper)
21
+ }
@@ -1,125 +1,125 @@
1
- <script type="text/javascript">
2
- function setDropdownAction() {
3
- let action = $('#node-input-action').val()
4
- $('#actionText').hide()
5
- $('#actionAttr').hide()
6
- $('#actionIndex').hide()
7
- $('#actionValue').hide()
8
- if (action == 'selectByAttr') {
9
- $('#actionAttr').show()
10
- $('#actionValue').show()
11
- }
12
- if (action == 'selectByIndex') {
13
- $('#actionIndex').show()
14
- }
15
- if (action == 'selectByText') {
16
- $('#actionText').show()
17
- }
18
- }
19
-
20
- RED.nodes.registerType('dropdown-action', {
21
- category: 'Webdriver IO',
22
- color: '#a6bbcf',
23
- defaults: {
24
- name: { value: '' },
25
- locateUsing: { value: 'xpath' },
26
- locateValue: { value: '' },
27
- action: { value: 'selectByAttr' },
28
- text: { value: '' },
29
- attribute: { value: '' },
30
- index: { value: '' },
31
- value: { value: '' }
32
- },
33
- inputs: 1,
34
- outputs: 1,
35
- icon: 'white-globe.png',
36
- label: function () {
37
- return this.name || 'dropdown action'
38
- },
39
- oneditprepare: function () {
40
- setDropdownAction()
41
- }
42
- })
43
- </script>
44
-
45
- <script type="text/x-red" data-template-name="dropdown-action">
46
- <div class="form-row">
47
- <label for="node-input-locateUsing"><i class="fa fa-tasks"></i> Locate Method</label>
48
- <select type="text" id="node-input-locateUsing" style="width:70%;">
49
- <option value="id">id</option>
50
- <option value="name">name</option>
51
- <option value="className">Class 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="setDropdownAction()">
67
- <option value="selectByAttr">Select by Attribute</option>
68
- <option value="selectByIndex">Select by Index</option>
69
- <option value="selectByText">Select by Visual text</option>
70
- <option value="getValue">Get Value</option>
71
- </select>
72
- </div>
73
- <div class="form-row" id="actionText">
74
- <label for="node-input-text"><i class="fa fa-tasks"></i> Text to Select</label>
75
- <input id="node-input-text" type="text">
76
- </div>
77
- <div class="form-row" id="actionAttr">
78
- <label for="node-input-attribute"><i class="fa fa-tasks"></i> Attribute Name</label>
79
- <input id="node-input-attribute" type="text">
80
- </div>
81
- <div class="form-row" id="actionValue">
82
- <label for="node-input-value"><i class="fa fa-tasks"></i> Value</label>
83
- <input id="node-input-value" type="text">
84
- </div>
85
- <div class="form-row" id="actionIndex">
86
- <label for="node-input-index"><i class="fa fa-tasks"></i> Index</label>
87
- <input id="node-input-index" type="text">
88
- </div>
89
- <div class="form-row">
90
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
91
- <input id="node-input-name" type="text">
92
- </div>
93
- </script>
94
-
95
- <script type="text/x-red" data-help-name="dropdown-action">
96
- <h3>Perform action on a dropdown selector</h3>
97
- <h3>Inputs</h3>
98
- <dl class="message-properties">
99
-
100
- <dt><code>mgs.locateUsing</code>: <span class="property-type">string</span></dt>
101
- <dd>specifies the type of web element identifier:
102
- <ul>
103
- <li>id</li>
104
- <li>name</li>
105
- <li>Class Name</li>
106
- <li>Jquery selector</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
- </dl>
113
-
114
- <h3>Details</h3>
115
- <p><b>Locate Method</b> specifies the method used to target the web element/dropdown. This option can be selected manually from the Properties panel OR it can be received from <code>mgs.locateUsing</code><br></p>
116
- <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>
117
- <p><b>Action</b> specifies the action to be performed on the target dropdown. Actions includes:
118
- <ul>
119
- <li>Select By Attribute</li>
120
- <li>Select By Index</li>
121
- <li>Select by Visual text</li>
122
- <li>Get Value</li>
123
- </ul>
124
- </p>
1
+ <script type="text/javascript">
2
+ function setDropdownAction() {
3
+ let action = $('#node-input-action').val()
4
+ $('#actionText').hide()
5
+ $('#actionAttr').hide()
6
+ $('#actionIndex').hide()
7
+ $('#actionValue').hide()
8
+ if (action == 'selectByAttr') {
9
+ $('#actionAttr').show()
10
+ $('#actionValue').show()
11
+ }
12
+ if (action == 'selectByIndex') {
13
+ $('#actionIndex').show()
14
+ }
15
+ if (action == 'selectByText') {
16
+ $('#actionText').show()
17
+ }
18
+ }
19
+
20
+ RED.nodes.registerType('dropdown-action', {
21
+ category: 'Webdriver IO',
22
+ color: '#a6bbcf',
23
+ defaults: {
24
+ name: { value: '' },
25
+ locateUsing: { value: 'xpath' },
26
+ locateValue: { value: '' },
27
+ action: { value: 'selectByAttr' },
28
+ text: { value: '' },
29
+ attribute: { value: '' },
30
+ index: { value: '' },
31
+ value: { value: '' }
32
+ },
33
+ inputs: 1,
34
+ outputs: 1,
35
+ icon: 'white-globe.png',
36
+ label: function () {
37
+ return this.name || 'dropdown action'
38
+ },
39
+ oneditprepare: function () {
40
+ setDropdownAction()
41
+ }
42
+ })
43
+ </script>
44
+
45
+ <script type="text/x-red" data-template-name="dropdown-action">
46
+ <div class="form-row">
47
+ <label for="node-input-locateUsing"><i class="fa fa-tasks"></i> Locate Method</label>
48
+ <select type="text" id="node-input-locateUsing" style="width:70%;">
49
+ <option value="id">id</option>
50
+ <option value="name">name</option>
51
+ <option value="className">Class 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="setDropdownAction()">
67
+ <option value="selectByAttr">Select by Attribute</option>
68
+ <option value="selectByIndex">Select by Index</option>
69
+ <option value="selectByText">Select by Visual text</option>
70
+ <option value="getValue">Get Value</option>
71
+ </select>
72
+ </div>
73
+ <div class="form-row" id="actionText">
74
+ <label for="node-input-text"><i class="fa fa-tasks"></i> Text to Select</label>
75
+ <input id="node-input-text" type="text">
76
+ </div>
77
+ <div class="form-row" id="actionAttr">
78
+ <label for="node-input-attribute"><i class="fa fa-tasks"></i> Attribute Name</label>
79
+ <input id="node-input-attribute" type="text">
80
+ </div>
81
+ <div class="form-row" id="actionValue">
82
+ <label for="node-input-value"><i class="fa fa-tasks"></i> Value</label>
83
+ <input id="node-input-value" type="text">
84
+ </div>
85
+ <div class="form-row" id="actionIndex">
86
+ <label for="node-input-index"><i class="fa fa-tasks"></i> Index</label>
87
+ <input id="node-input-index" type="text">
88
+ </div>
89
+ <div class="form-row">
90
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
91
+ <input id="node-input-name" type="text">
92
+ </div>
93
+ </script>
94
+
95
+ <script type="text/x-red" data-help-name="dropdown-action">
96
+ <h3>Perform action on a dropdown selector</h3>
97
+ <h3>Inputs</h3>
98
+ <dl class="message-properties">
99
+
100
+ <dt><code>mgs.locateUsing</code>: <span class="property-type">string</span></dt>
101
+ <dd>specifies the type of web element identifier:
102
+ <ul>
103
+ <li>id</li>
104
+ <li>name</li>
105
+ <li>Class Name</li>
106
+ <li>Jquery selector</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
+ </dl>
113
+
114
+ <h3>Details</h3>
115
+ <p><b>Locate Method</b> specifies the method used to target the web element/dropdown. This option can be selected manually from the Properties panel OR it can be received from <code>mgs.locateUsing</code><br></p>
116
+ <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>
117
+ <p><b>Action</b> specifies the action to be performed on the target dropdown. Actions includes:
118
+ <ul>
119
+ <li>Select By Attribute</li>
120
+ <li>Select By Index</li>
121
+ <li>Select by Visual text</li>
122
+ <li>Get Value</li>
123
+ </ul>
124
+ </p>
125
125
  </script>