topological-nodered-wdio 0.5.4 → 1.0.0

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,92 +1,92 @@
1
- <script type="text/javascript">
2
- RED.nodes.registerType('execute-script', {
3
- category: 'Webdriver IO',
4
- color: '#a6bbcf',
5
- defaults: {
6
- name: { value: '' },
7
- locateUsing: { value: 'xpath' },
8
- locateValue: { value: '' },
9
- action: { value: 'sync' },
10
- script: { value: '' }
11
- },
12
- inputs: 1,
13
- outputs: 1,
14
- icon: 'white-globe.png',
15
- label: function() {
16
- return this.name || 'execute script'
17
- }
18
- })
19
- </script>
20
-
21
- <script type="text/x-red" data-template-name="execute-script">
22
- <div class="form-row">
23
- <label for="node-input-locateUsing"><i class="fa fa-tasks"></i> Locate Method</label>
24
- <select type="text" id="node-input-locateUsing" style="width:70%;">
25
- <option value="id">id</option>
26
- <option value="name">name</option>
27
- <option value="css selector">CSS selector</option>
28
- <option value="link text">Link text</option>
29
- <option value="partial link text">Partial link text</option>
30
- <option value="tag name">Tag name</option>
31
- <option value="xpath" selected>XPath</option>
32
- </select>
33
- </div>
34
- <div class="form-row">
35
- <label for="node-input-locateValue"><i class="fa fa-tasks"></i> Selector</label>
36
- <input id="node-input-locateValue" type="text">
37
- </div>
38
- <div class="form-row">
39
- <label for="node-input-action"><i class="fa fa-tasks"></i> Action</label>
40
- <select type="text" id="node-input-action" style="width:70%;">
41
- <option value="sync">Sync</option>
42
- <option value="aSync">Async</option>
43
- </select>
44
- </div>
45
- <div class="form-row">
46
- <label for="node-input-script"><i class="fa fa-tasks"></i> Script</label>
47
- <input id="node-input-script" type="text" placeholder="javascript in string">
48
- </div>
49
- <div class="form-row">
50
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
51
- <input id="node-input-name" type="text">
52
- </div>
53
- </script>
54
-
55
- <script type="text/x-red" data-help-name="execute-script">
56
- <h3>Execute javascript commands on a target web element.</h3>
57
- <h3>Inputs</h3>
58
- <dl class="message-properties">
59
-
60
- <dt><code>mgs.locateUsing</code>: <span class="property-type">string</span></dt>
61
- <dd>specifies the type of web element identifier:
62
- <ul>
63
- <li>id</li>
64
- <li>name</li>
65
- <li>CSS selector</li>
66
- <li>Link text</li>
67
- <li>Partial link text</li>
68
- <li>Tag name</li>
69
- <li>XPath</li>
70
- </ul>
71
- <br>
72
- </dd>
73
- <dt><code>msg.locateValue</code><span class="property-type">string</span></dt>
74
- <dd>value passed to the web element identifier (Locate Method)<br></dd>
75
-
76
- <dt><code>msg.script</code><span class="property-type">string</span></dt>
77
- <dd>This is the script that would run in the context frame; the selected web element(Selector) would be passed as an argument.</dd>
78
- </dl>
79
-
80
- <h3>Details</h3>
81
- <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>
82
- <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>
83
- <p><b>Action</b>
84
- <ul>
85
- <li>Sync: executes a JavaScript function in the context of the current browsing context. Selector is passed in as an argument. <code>browser.executeScript(script, args)</code></li>
86
- <li>Async: inject a snippet of JavaScript into the page for asynchronous execution in the context of the currently selected frame. Selector is passed in as argument/ <code>browser.executeAsyncScript(script, args)</code></li>
87
- </ul>
88
- </p>
89
- <p><b>Script</b> The script that would would run in the context browser<br></p>
90
- </script>
91
-
92
-
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('execute-script', {
3
+ category: 'Webdriver IO',
4
+ color: '#a6bbcf',
5
+ defaults: {
6
+ name: { value: '' },
7
+ locateUsing: { value: 'xpath' },
8
+ locateValue: { value: '' },
9
+ action: { value: 'sync' },
10
+ script: { value: '' }
11
+ },
12
+ inputs: 1,
13
+ outputs: 1,
14
+ icon: 'white-globe.png',
15
+ label: function() {
16
+ return this.name || 'execute script'
17
+ }
18
+ })
19
+ </script>
20
+
21
+ <script type="text/x-red" data-template-name="execute-script">
22
+ <div class="form-row">
23
+ <label for="node-input-locateUsing"><i class="fa fa-tasks"></i> Locate Method</label>
24
+ <select type="text" id="node-input-locateUsing" style="width:70%;">
25
+ <option value="id">id</option>
26
+ <option value="name">name</option>
27
+ <option value="css selector">CSS selector</option>
28
+ <option value="link text">Link text</option>
29
+ <option value="partial link text">Partial link text</option>
30
+ <option value="tag name">Tag name</option>
31
+ <option value="xpath" selected>XPath</option>
32
+ </select>
33
+ </div>
34
+ <div class="form-row">
35
+ <label for="node-input-locateValue"><i class="fa fa-tasks"></i> Selector</label>
36
+ <input id="node-input-locateValue" type="text">
37
+ </div>
38
+ <div class="form-row">
39
+ <label for="node-input-action"><i class="fa fa-tasks"></i> Action</label>
40
+ <select type="text" id="node-input-action" style="width:70%;">
41
+ <option value="sync">Sync</option>
42
+ <option value="aSync">Async</option>
43
+ </select>
44
+ </div>
45
+ <div class="form-row">
46
+ <label for="node-input-script"><i class="fa fa-tasks"></i> Script</label>
47
+ <input id="node-input-script" type="text" placeholder="javascript in string">
48
+ </div>
49
+ <div class="form-row">
50
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
51
+ <input id="node-input-name" type="text">
52
+ </div>
53
+ </script>
54
+
55
+ <script type="text/x-red" data-help-name="execute-script">
56
+ <h3>Execute javascript commands on a target web element.</h3>
57
+ <h3>Inputs</h3>
58
+ <dl class="message-properties">
59
+
60
+ <dt><code>mgs.locateUsing</code>: <span class="property-type">string</span></dt>
61
+ <dd>specifies the type of web element identifier:
62
+ <ul>
63
+ <li>id</li>
64
+ <li>name</li>
65
+ <li>CSS selector</li>
66
+ <li>Link text</li>
67
+ <li>Partial link text</li>
68
+ <li>Tag name</li>
69
+ <li>XPath</li>
70
+ </ul>
71
+ <br>
72
+ </dd>
73
+ <dt><code>msg.locateValue</code><span class="property-type">string</span></dt>
74
+ <dd>value passed to the web element identifier (Locate Method)<br></dd>
75
+
76
+ <dt><code>msg.script</code><span class="property-type">string</span></dt>
77
+ <dd>This is the script that would run in the context frame; the selected web element(Selector) would be passed as an argument.</dd>
78
+ </dl>
79
+
80
+ <h3>Details</h3>
81
+ <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>
82
+ <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>
83
+ <p><b>Action</b>
84
+ <ul>
85
+ <li>Sync: executes a JavaScript function in the context of the current browsing context. Selector is passed in as an argument. <code>browser.executeScript(script, args)</code></li>
86
+ <li>Async: inject a snippet of JavaScript into the page for asynchronous execution in the context of the currently selected frame. Selector is passed in as argument/ <code>browser.executeAsyncScript(script, args)</code></li>
87
+ </ul>
88
+ </p>
89
+ <p><b>Script</b> The script that would would run in the context browser<br></p>
90
+ </script>
91
+
92
+
@@ -1,40 +1,40 @@
1
- const common = require('./wdio-common')
2
-
3
- module.exports = function(RED) {
4
- function executeScript(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 element = await common.getElement(
16
- browser,
17
- locateUsing,
18
- locateValue
19
- )
20
-
21
- let script = config.script || msg.script
22
-
23
- if (config.action === 'sync') {
24
- node.log = `Execute synchronous Javascript: "${script}"${element?` By passing the webelement identified using ${locateUsing}: "${locateValue}"`:''}.`
25
- await browser.executeScript(script, Array.from(element))
26
- } else if (config.action === 'aSync') {
27
- node.log = `Execute the asynchronous Javascript: "${script}"${element?` By passing the webelement identified using ${locateUsing}: "${locateValue}"`:''}.`
28
- await browser.executeAsyncScript(script, Array.from(element))
29
- }
30
- await common.log(node)
31
- common.successStatus(node)
32
- node.send(msg)
33
- } catch (e) {
34
- await common.log(node)
35
- common.handleError(e, node, msg)
36
- }
37
- })
38
- }
39
- RED.nodes.registerType('execute-script', executeScript)
40
- }
1
+ const common = require('./wdio-common')
2
+
3
+ module.exports = function(RED) {
4
+ function executeScript(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 element = await common.getElement(
16
+ browser,
17
+ locateUsing,
18
+ locateValue
19
+ )
20
+
21
+ let script = config.script || msg.script
22
+
23
+ if (config.action === 'sync') {
24
+ node.log = `Execute synchronous Javascript: "${script}"${element?` By passing the webelement identified using ${locateUsing}: "${locateValue}"`:''}.`
25
+ await browser.executeScript(script, Array.from(element))
26
+ } else if (config.action === 'aSync') {
27
+ node.log = `Execute the asynchronous Javascript: "${script}"${element?` By passing the webelement identified using ${locateUsing}: "${locateValue}"`:''}.`
28
+ await browser.executeAsyncScript(script, Array.from(element))
29
+ }
30
+ await common.log(node)
31
+ common.successStatus(node)
32
+ node.send(msg)
33
+ } catch (e) {
34
+ await common.log(node)
35
+ common.handleError(e, node, msg)
36
+ }
37
+ })
38
+ }
39
+ RED.nodes.registerType('execute-script', executeScript)
40
+ }
@@ -1,127 +1,127 @@
1
- <script type="text/javascript">
2
- function setExplicitAction() {
3
- let action = $('#node-input-action').val()
4
- $('#actionTime').show()
5
- $('#actionReverse').show()
6
- $('#actionError').show()
7
- if (action === 'until') {
8
- $('#actionTime').hide()
9
- $('#actionReverse').hide()
10
- $('#actionError').hide()
11
- }
12
- }
13
-
14
- RED.nodes.registerType('explicit-wait', {
15
- category: 'Webdriver IO',
16
- color: '#a6bbcf',
17
- defaults: {
18
- name: { value: '' },
19
- locateUsing: { value: 'xpath' },
20
- locateValue: { value: '' },
21
- action: { value: '' },
22
- time: { value: '' },
23
- reverse: { value: 'false' },
24
- error: { value: '' }
25
- },
26
- inputs: 1,
27
- outputs: 1,
28
- icon: 'white-globe.png',
29
- label: function() {
30
- return this.name || 'explicit wait'
31
- },
32
- oneditprepare: function() {
33
- setExplicitAction()
34
- }
35
- })
36
- </script>
37
-
38
- <script type="text/x-red" data-template-name="explicit-wait">
39
- <div class="form-row">
40
- <label for="node-input-locateUsing"><i class="fa fa-tasks"></i> Locate Method</label>
41
- <select type="text" id="node-input-locateUsing" style="width:70%;">
42
- <option value="id">id</option>
43
- <option value="name">name</option>
44
- <option value="className">Class Name</option>
45
- <option value="css selector">CSS selector</option>
46
- <option value="link text">Link text</option>
47
- <option value="partial link text">Partial link text</option>
48
- <option value="tag name">Tag name</option>
49
- <option value="xpath" selected>XPath</option>
50
- </select>
51
- </div>
52
- <div class="form-row">
53
- <label for="node-input-locateValue"><i class="fa fa-tasks"></i> Selector</label>
54
- <input id="node-input-locateValue" type="text">
55
- </div>
56
- <div class="form-row">
57
- <label for="node-input-action"><i class="fa fa-tasks"></i> Action</label>
58
- <select type="text" id="node-input-action" style="width:70%;" onchange="setExplicitAction()">
59
- <option value="displayed">Wait for Displayed</option>
60
- <option value="enabled">Wait for Enabled</option>
61
- <option value="exists">Wait for Exist</option>
62
- <!-- <option value="until">Wait Until</option> -->
63
- </select>
64
- </div>
65
- <div class="form-row" id="actionTime" >
66
- <label for="node-input-time"><i class="fa fa-tasks"></i> Time to Wait</label>
67
- <input id="node-input-time" type="text" placeholder="in ms">
68
- </div>
69
- <div class="form-row" id="actionReverse" >
70
- <label for="node-input-reverse"><i class="fa fa-tasks"></i> Reverse</label>
71
- <select type="text" id="node-input-reverse" style="width:70%;">
72
- <option value="false">false</option>
73
- <option value="true">true</option>
74
- </select>
75
- </div>
76
- <div class="form-row" id="actionError" >
77
- <label for="node-input-error"><i class="fa fa-tasks"></i> Error Message</label>
78
- <input id="node-input-error" type="text" placeholder="error message">
79
- </div>
80
- <div class="form-row">
81
- <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
82
- <input id="node-input-name" type="text">
83
- </div>
84
- </script>
85
-
86
- <script type="text/x-red" data-help-name="explicit-wait">
87
- <h3>The Set Timeouts command sets timeout durations associated with the current session.</h3>
88
- <h3>Inputs</h3>
89
- <dl class="message-properties">
90
- <dt><code>mgs.locateUsing</code>: <span class="property-type">string</span></dt>
91
- <dd>specifies the type of web element identifier:
92
- <ul>
93
- <li>id</li>
94
- <li>name</li>
95
- <li>CSS selector</li>
96
- <li>Link text</li>
97
- <li>Partial link text</li>
98
- <li>Tag name</li>
99
- <li>XPath</li>
100
- </ul>
101
- <br>
102
- </dd>
103
- <dt><code>msg.locateValue</code><span class="property-type">string</span></dt>
104
- <dd>value passed to the web element identifier (Locate Method)<br></dd>
105
-
106
- <dt><code>msg.reverse</code><span class="property-type">boolean</span></dt>
107
- <dd>If set to true, webdriver will wait for the <i>opposite</i> of the action selected<br></dd>
108
- </dl>
109
-
110
- <h3>Details</h3>
111
- <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>
112
- <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>
113
- <p><b>Action</b> to perform on the pop-up alert/window:
114
- <ul>
115
- <li>Wait for Displayed</li>
116
- <li>Wait for Enabled</li>
117
- <li>Wait for Exist</li>
118
- <li>Wait Until</li>
119
- </ul>
120
- </p>
121
- <p><b>Time to Wait</b> Set time to wait in milliseconds. <br></p>
122
- <p><b>Reverse</b> If set to true, webdriver will wait for the <i>opposite</i> of the action selected. <br></p>
123
- <p><b>Error Message</b> If an error exists this error message overrides the default error message. <br></p>
124
-
125
-
126
-
1
+ <script type="text/javascript">
2
+ function setExplicitAction() {
3
+ let action = $('#node-input-action').val()
4
+ $('#actionTime').show()
5
+ $('#actionReverse').show()
6
+ $('#actionError').show()
7
+ if (action === 'until') {
8
+ $('#actionTime').hide()
9
+ $('#actionReverse').hide()
10
+ $('#actionError').hide()
11
+ }
12
+ }
13
+
14
+ RED.nodes.registerType('explicit-wait', {
15
+ category: 'Webdriver IO',
16
+ color: '#a6bbcf',
17
+ defaults: {
18
+ name: { value: '' },
19
+ locateUsing: { value: 'xpath' },
20
+ locateValue: { value: '' },
21
+ action: { value: '' },
22
+ time: { value: '' },
23
+ reverse: { value: 'false' },
24
+ error: { value: '' }
25
+ },
26
+ inputs: 1,
27
+ outputs: 1,
28
+ icon: 'white-globe.png',
29
+ label: function() {
30
+ return this.name || 'explicit wait'
31
+ },
32
+ oneditprepare: function() {
33
+ setExplicitAction()
34
+ }
35
+ })
36
+ </script>
37
+
38
+ <script type="text/x-red" data-template-name="explicit-wait">
39
+ <div class="form-row">
40
+ <label for="node-input-locateUsing"><i class="fa fa-tasks"></i> Locate Method</label>
41
+ <select type="text" id="node-input-locateUsing" style="width:70%;">
42
+ <option value="id">id</option>
43
+ <option value="name">name</option>
44
+ <option value="className">Class Name</option>
45
+ <option value="css selector">CSS selector</option>
46
+ <option value="link text">Link text</option>
47
+ <option value="partial link text">Partial link text</option>
48
+ <option value="tag name">Tag name</option>
49
+ <option value="xpath" selected>XPath</option>
50
+ </select>
51
+ </div>
52
+ <div class="form-row">
53
+ <label for="node-input-locateValue"><i class="fa fa-tasks"></i> Selector</label>
54
+ <input id="node-input-locateValue" type="text">
55
+ </div>
56
+ <div class="form-row">
57
+ <label for="node-input-action"><i class="fa fa-tasks"></i> Action</label>
58
+ <select type="text" id="node-input-action" style="width:70%;" onchange="setExplicitAction()">
59
+ <option value="displayed">Wait for Displayed</option>
60
+ <option value="enabled">Wait for Enabled</option>
61
+ <option value="exists">Wait for Exist</option>
62
+ <!-- <option value="until">Wait Until</option> -->
63
+ </select>
64
+ </div>
65
+ <div class="form-row" id="actionTime" >
66
+ <label for="node-input-time"><i class="fa fa-tasks"></i> Time to Wait</label>
67
+ <input id="node-input-time" type="text" placeholder="in ms">
68
+ </div>
69
+ <div class="form-row" id="actionReverse" >
70
+ <label for="node-input-reverse"><i class="fa fa-tasks"></i> Reverse</label>
71
+ <select type="text" id="node-input-reverse" style="width:70%;">
72
+ <option value="false">false</option>
73
+ <option value="true">true</option>
74
+ </select>
75
+ </div>
76
+ <div class="form-row" id="actionError" >
77
+ <label for="node-input-error"><i class="fa fa-tasks"></i> Error Message</label>
78
+ <input id="node-input-error" type="text" placeholder="error message">
79
+ </div>
80
+ <div class="form-row">
81
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
82
+ <input id="node-input-name" type="text">
83
+ </div>
84
+ </script>
85
+
86
+ <script type="text/x-red" data-help-name="explicit-wait">
87
+ <h3>The Set Timeouts command sets timeout durations associated with the current session.</h3>
88
+ <h3>Inputs</h3>
89
+ <dl class="message-properties">
90
+ <dt><code>mgs.locateUsing</code>: <span class="property-type">string</span></dt>
91
+ <dd>specifies the type of web element identifier:
92
+ <ul>
93
+ <li>id</li>
94
+ <li>name</li>
95
+ <li>CSS selector</li>
96
+ <li>Link text</li>
97
+ <li>Partial link text</li>
98
+ <li>Tag name</li>
99
+ <li>XPath</li>
100
+ </ul>
101
+ <br>
102
+ </dd>
103
+ <dt><code>msg.locateValue</code><span class="property-type">string</span></dt>
104
+ <dd>value passed to the web element identifier (Locate Method)<br></dd>
105
+
106
+ <dt><code>msg.reverse</code><span class="property-type">boolean</span></dt>
107
+ <dd>If set to true, webdriver will wait for the <i>opposite</i> of the action selected<br></dd>
108
+ </dl>
109
+
110
+ <h3>Details</h3>
111
+ <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>
112
+ <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>
113
+ <p><b>Action</b> to perform on the pop-up alert/window:
114
+ <ul>
115
+ <li>Wait for Displayed</li>
116
+ <li>Wait for Enabled</li>
117
+ <li>Wait for Exist</li>
118
+ <li>Wait Until</li>
119
+ </ul>
120
+ </p>
121
+ <p><b>Time to Wait</b> Set time to wait in milliseconds. <br></p>
122
+ <p><b>Reverse</b> If set to true, webdriver will wait for the <i>opposite</i> of the action selected. <br></p>
123
+ <p><b>Error Message</b> If an error exists this error message overrides the default error message. <br></p>
124
+
125
+
126
+
127
127
  </script>
@@ -1,48 +1,48 @@
1
- const common = require('./wdio-common')
2
-
3
- module.exports = function(RED) {
4
- function explicitWait(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
-
21
- let time = parseInt(config.time || msg.time)
22
- let reverse = config.reverse === 'true' || msg.reverse
23
- let error = config.error || msg.error
24
-
25
- if (config.action === 'displayed') {
26
- node.log = `Waiting for the element to be displayed for ${time}, identified using ${locateUsing}: "${locateValue}".`
27
- await browser.$(locator).waitForDisplayed({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
28
- } else if (config.action === 'enabled') {
29
- node.log = `Waiting for the element to be enabled for ${time}, identified using ${locateUsing}: "${locateValue}".`
30
- await browser.$(locator).waitForEnabled({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
31
- } else if (config.action === 'exists') {
32
- node.log = `Waiting for the element to be exists for ${time}, identified using ${locateUsing}: "${locateValue}".`
33
- await browser.$(locator).waitForExist({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
34
- } else if (config.action === 'until') {
35
- await browser.$(locator).waitUntil()
36
- }
37
-
38
- await common.log(node)
39
- common.successStatus(node)
40
- node.send(msg)
41
- } catch (e) {
42
- await common.log(node)
43
- common.handleError(e, node, msg)
44
- }
45
- })
46
- }
47
- RED.nodes.registerType('explicit-wait', explicitWait)
48
- }
1
+ const common = require('./wdio-common')
2
+
3
+ module.exports = function(RED) {
4
+ function explicitWait(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
+
21
+ let time = parseInt(config.time || msg.time)
22
+ let reverse = config.reverse === 'true' || msg.reverse
23
+ let error = config.error || msg.error
24
+
25
+ if (config.action === 'displayed') {
26
+ node.log = `Waiting for the element to be displayed for ${time}, identified using ${locateUsing}: "${locateValue}".`
27
+ await browser.$(locator).waitForDisplayed({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
28
+ } else if (config.action === 'enabled') {
29
+ node.log = `Waiting for the element to be enabled for ${time}, identified using ${locateUsing}: "${locateValue}".`
30
+ await browser.$(locator).waitForEnabled({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
31
+ } else if (config.action === 'exists') {
32
+ node.log = `Waiting for the element to be exists for ${time}, identified using ${locateUsing}: "${locateValue}".`
33
+ await browser.$(locator).waitForExist({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
34
+ } else if (config.action === 'until') {
35
+ await browser.$(locator).waitUntil()
36
+ }
37
+
38
+ await common.log(node)
39
+ common.successStatus(node)
40
+ node.send(msg)
41
+ } catch (e) {
42
+ await common.log(node)
43
+ common.handleError(e, node, msg)
44
+ }
45
+ })
46
+ }
47
+ RED.nodes.registerType('explicit-wait', explicitWait)
48
+ }