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.
- package/LICENSE +20 -20
- package/README.md +15 -15
- package/examples/basic.json +332 -332
- package/package.json +43 -44
- package/src/alert-action.html +79 -79
- package/src/alert-action.js +52 -52
- package/src/browser-action.html +128 -114
- package/src/browser-action.js +85 -70
- package/src/delete-session.html +26 -26
- package/src/delete-session.js +29 -29
- package/src/document-helper.html +59 -59
- package/src/document-helper.js +23 -23
- package/src/dropdown-action.html +124 -124
- package/src/dropdown-action.js +50 -50
- package/src/element-action.html +133 -133
- package/src/element-action.js +105 -105
- package/src/element-check.html +90 -90
- package/src/element-check.js +62 -62
- package/src/execute-script.html +92 -92
- package/src/execute-script.js +40 -40
- package/src/explicit-wait.html +126 -126
- package/src/explicit-wait.js +48 -48
- package/src/frame-action.html +67 -67
- package/src/frame-action.js +38 -38
- package/src/implicit-wait-config.html +85 -85
- package/src/implicit-wait-config.js +41 -41
- package/src/new-session.html +96 -96
- package/src/new-session.js +108 -108
- package/src/wdio-common.js +163 -163
- package/src/window-action.html +91 -91
- package/src/window-action.js +43 -43
package/src/browser-action.js
CHANGED
|
@@ -1,70 +1,85 @@
|
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
await
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
+
let filePath = config.filePath || msg.filePath
|
|
18
|
+
|
|
19
|
+
if (config.action === 'getUrl') {
|
|
20
|
+
node.log = 'Get the url of the web page.'
|
|
21
|
+
msg.payload = await browser.getUrl()
|
|
22
|
+
} else if (config.action === 'navigateTo') {
|
|
23
|
+
node.log = `Navigate to url: "${url}".`
|
|
24
|
+
await browser.navigateTo(url)
|
|
25
|
+
} else if (config.action === 'back') {
|
|
26
|
+
node.log = 'Go to previous page (browser back feature).'
|
|
27
|
+
await browser.back()
|
|
28
|
+
} else if (config.action === 'forward') {
|
|
29
|
+
node.log = 'Go for next page (browser forward feature).'
|
|
30
|
+
await browser.forward()
|
|
31
|
+
} else if (config.action === 'refresh') {
|
|
32
|
+
node.log = 'Refresh the web page.'
|
|
33
|
+
await browser.refresh()
|
|
34
|
+
} else if (config.action === 'getTitle') {
|
|
35
|
+
node.log = 'Get the title of the browser window.'
|
|
36
|
+
msg.payload = await browser.getTitle()
|
|
37
|
+
} else if (config.action === 'setSize') {
|
|
38
|
+
node.log = `Set the Size of browser window to Width: ${width}, Height: ${height}.`
|
|
39
|
+
await browser.setWindowSize(parseInt(width), parseInt(height))
|
|
40
|
+
} else if (config.action === 'maximize') {
|
|
41
|
+
node.log = 'Maximize the browser window.'
|
|
42
|
+
await browser.maximizeWindow()
|
|
43
|
+
} else if (config.action === 'takeScreenShot') {
|
|
44
|
+
node.log = 'Take the screenshot of the browser window.'
|
|
45
|
+
msg.payload = await browser.takeScreenshot()
|
|
46
|
+
} else if (config.action === 'takeFullScreenShot') {
|
|
47
|
+
node.log = 'Take the full screenshot of the browser window.'
|
|
48
|
+
const puppeteerBrowser = await browser.getPuppeteer()
|
|
49
|
+
const pages = await puppeteerBrowser.pages()
|
|
50
|
+
await pages[0].screenshot({ path: filePath, fullPage: true })
|
|
51
|
+
msg.payload = `Full screenshot saved to path: ${filePath}`
|
|
52
|
+
} else if (config.action === 'pageSource') {
|
|
53
|
+
node.log = 'Get the Page source (Source code of the web page).'
|
|
54
|
+
msg.payload = await browser.getPageSource()
|
|
55
|
+
} else if (config.action === 'getMHTML') {
|
|
56
|
+
node.log = 'Get the MHTML (web page archive) of the web page.'
|
|
57
|
+
const puppeteerBrowser = await browser.getPuppeteer()
|
|
58
|
+
const pages = await puppeteerBrowser.pages()
|
|
59
|
+
const client = await pages[0].target().createCDPSession()
|
|
60
|
+
await client.send('Page.enable')
|
|
61
|
+
const {data} = await client.send('Page.captureSnapshot', { format: 'mhtml' })
|
|
62
|
+
msg.payload = data
|
|
63
|
+
} else if (config.action === 'getCookies') {
|
|
64
|
+
node.log = 'Get the cookies stored.'
|
|
65
|
+
msg.payload = await browser.getAllCookies()
|
|
66
|
+
} else if (config.action === 'print') {
|
|
67
|
+
node.log = 'Print the page.'
|
|
68
|
+
await browser.execute('setTimeout(()=> {window.print()}, 2000)')
|
|
69
|
+
} else if (config.action === 'keyStrokes') {
|
|
70
|
+
node.log = `Enter the provide keystrokes: ${key}.`
|
|
71
|
+
let arr = keys.split(',')
|
|
72
|
+
let keyValues = arr.map((item) => item.trim())
|
|
73
|
+
await browser.keys(Array.from(keyValues))
|
|
74
|
+
}
|
|
75
|
+
await common.log(node)
|
|
76
|
+
common.successStatus(node)
|
|
77
|
+
node.send(msg)
|
|
78
|
+
} catch (e) {
|
|
79
|
+
await common.log(node)
|
|
80
|
+
common.handleError(e, node, msg)
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
RED.nodes.registerType('browser-action', browserAction)
|
|
85
|
+
}
|
package/src/delete-session.html
CHANGED
|
@@ -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>
|
package/src/delete-session.js
CHANGED
|
@@ -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
|
+
}
|
package/src/document-helper.html
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
<script type="text/javascript">
|
|
2
|
-
|
|
3
|
-
function setValue() {
|
|
4
|
-
return $('#node-input-line').val()
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function setChanges() {
|
|
8
|
-
return $('#node-input-refUrl').val()
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
RED.nodes.registerType('document-helper', {
|
|
12
|
-
category: 'Webdriver IO',
|
|
13
|
-
color: '#FFFFFF',
|
|
14
|
-
defaults: {
|
|
15
|
-
name: { value: '' },
|
|
16
|
-
refUrl: {value: setChanges()},
|
|
17
|
-
line: {value: setValue()}
|
|
18
|
-
},
|
|
19
|
-
inputs: 1,
|
|
20
|
-
outputs: 1,
|
|
21
|
-
icon: 'font-awesome/fa-file-text-o',
|
|
22
|
-
label: function() {
|
|
23
|
-
return this.name || 'document-helper'
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
</script>
|
|
27
|
-
|
|
28
|
-
<script type="text/x-red" data-template-name="document-helper">
|
|
29
|
-
|
|
30
|
-
<div class="form-row">
|
|
31
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
32
|
-
<input id="node-input-name" type="text">
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<div class="form-row">
|
|
36
|
-
<input type="checkbox" id="node-input-line" name="node-input-line" onclick="setValue()" style="width:auto; margin-right:20%" />
|
|
37
|
-
<label for="node-input-line" style="min-width:70%;color:#87A980"><b> Use new line as separator</b></label>
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
<div class="form-row">
|
|
41
|
-
<label for="node-input-refUrl"><i class="fa fa-tag"></i> Ref. URl</label>
|
|
42
|
-
<textarea id="node-input-refUrl" name="node-input-refUrl" class="node-text-editor" rows="3" style="min-width:70%;" onblur="setChanges()"></textarea>
|
|
43
|
-
</div>
|
|
44
|
-
</script>
|
|
45
|
-
|
|
46
|
-
<script type="text/x-red" data-help-name="document-helper">
|
|
47
|
-
<h3>Log helper node uses to add notes to <code>global.document</code></h3>
|
|
48
|
-
<h3>Details</h3>
|
|
49
|
-
<dl class="message-properties">
|
|
50
|
-
<dt>Name: name of the log to be added to <code>global.document</code></dt>
|
|
51
|
-
<dt>New Line: Check the checkbox for Use new line as separator</dt>
|
|
52
|
-
<dt>Ref Url.: A quick reference url that needs to be added to document.</dt>
|
|
53
|
-
</dl>
|
|
54
|
-
|
|
55
|
-
<h3>Outputs</h3>
|
|
56
|
-
<dl class="message-properties">
|
|
57
|
-
<dt>msg: <span class="property-type">object</span></dt>
|
|
58
|
-
</dl>
|
|
59
|
-
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
|
|
3
|
+
function setValue() {
|
|
4
|
+
return $('#node-input-line').val()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function setChanges() {
|
|
8
|
+
return $('#node-input-refUrl').val()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
RED.nodes.registerType('document-helper', {
|
|
12
|
+
category: 'Webdriver IO',
|
|
13
|
+
color: '#FFFFFF',
|
|
14
|
+
defaults: {
|
|
15
|
+
name: { value: '' },
|
|
16
|
+
refUrl: {value: setChanges()},
|
|
17
|
+
line: {value: setValue()}
|
|
18
|
+
},
|
|
19
|
+
inputs: 1,
|
|
20
|
+
outputs: 1,
|
|
21
|
+
icon: 'font-awesome/fa-file-text-o',
|
|
22
|
+
label: function() {
|
|
23
|
+
return this.name || 'document-helper'
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<script type="text/x-red" data-template-name="document-helper">
|
|
29
|
+
|
|
30
|
+
<div class="form-row">
|
|
31
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
32
|
+
<input id="node-input-name" type="text">
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div class="form-row">
|
|
36
|
+
<input type="checkbox" id="node-input-line" name="node-input-line" onclick="setValue()" style="width:auto; margin-right:20%" />
|
|
37
|
+
<label for="node-input-line" style="min-width:70%;color:#87A980"><b> Use new line as separator</b></label>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div class="form-row">
|
|
41
|
+
<label for="node-input-refUrl"><i class="fa fa-tag"></i> Ref. URl</label>
|
|
42
|
+
<textarea id="node-input-refUrl" name="node-input-refUrl" class="node-text-editor" rows="3" style="min-width:70%;" onblur="setChanges()"></textarea>
|
|
43
|
+
</div>
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<script type="text/x-red" data-help-name="document-helper">
|
|
47
|
+
<h3>Log helper node uses to add notes to <code>global.document</code></h3>
|
|
48
|
+
<h3>Details</h3>
|
|
49
|
+
<dl class="message-properties">
|
|
50
|
+
<dt>Name: name of the log to be added to <code>global.document</code></dt>
|
|
51
|
+
<dt>New Line: Check the checkbox for Use new line as separator</dt>
|
|
52
|
+
<dt>Ref Url.: A quick reference url that needs to be added to document.</dt>
|
|
53
|
+
</dl>
|
|
54
|
+
|
|
55
|
+
<h3>Outputs</h3>
|
|
56
|
+
<dl class="message-properties">
|
|
57
|
+
<dt>msg: <span class="property-type">object</span></dt>
|
|
58
|
+
</dl>
|
|
59
|
+
|
|
60
60
|
</script>
|
package/src/document-helper.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
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
|
-
node.refUrl = config.refUrl
|
|
8
|
-
node.line = config.line
|
|
9
|
-
common.clearStatus(node)
|
|
10
|
-
|
|
11
|
-
node.on('input', async (msg) => {
|
|
12
|
-
try {
|
|
13
|
-
common.document(node)
|
|
14
|
-
node.send(msg)
|
|
15
|
-
common.successStatus(node)
|
|
16
|
-
} catch (e) {
|
|
17
|
-
await common.log(node)
|
|
18
|
-
common.handleError(e, node, msg)
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
RED.nodes.registerType('document-helper', documentHelper)
|
|
23
|
-
}
|
|
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
|
+
node.refUrl = config.refUrl
|
|
8
|
+
node.line = config.line
|
|
9
|
+
common.clearStatus(node)
|
|
10
|
+
|
|
11
|
+
node.on('input', async (msg) => {
|
|
12
|
+
try {
|
|
13
|
+
common.document(node)
|
|
14
|
+
node.send(msg)
|
|
15
|
+
common.successStatus(node)
|
|
16
|
+
} catch (e) {
|
|
17
|
+
await common.log(node)
|
|
18
|
+
common.handleError(e, node, msg)
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
RED.nodes.registerType('document-helper', documentHelper)
|
|
23
|
+
}
|