topological-nodered-wdio 1.1.3 → 1.1.5
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/package.json +1 -1
- package/src/element-check.js +22 -26
- package/src/explicit-wait.html +1 -1
package/package.json
CHANGED
package/src/element-check.js
CHANGED
|
@@ -13,25 +13,30 @@ module.exports = function (RED) {
|
|
|
13
13
|
let locateValues = config.locateValues || msg.locateValues;
|
|
14
14
|
let locateUsing = config.locateUsing || msg.locateUsing;
|
|
15
15
|
let locateValue = config.locateValue || msg.locateValue;
|
|
16
|
+
let element = null;
|
|
17
|
+
node.log = "";
|
|
16
18
|
|
|
17
19
|
let browser = await common.getBrowser(context);
|
|
18
|
-
let elementId = null;
|
|
19
|
-
node.log = "";
|
|
20
20
|
|
|
21
21
|
if (!multiple) {
|
|
22
|
-
|
|
23
|
-
browser,
|
|
22
|
+
let locator = await common.getLocator(
|
|
24
23
|
locateUsing,
|
|
25
24
|
locateValue
|
|
26
|
-
)
|
|
27
|
-
|
|
25
|
+
)
|
|
26
|
+
element = await browser.$(locator)
|
|
27
|
+
if (!element) {
|
|
28
28
|
throw new Error(`Element not found using ${locateUsing}: ${locateValue}`);
|
|
29
29
|
}
|
|
30
|
-
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
31
32
|
for (let i = 0; i < locateValues.length; i++) {
|
|
32
33
|
const { using, value } = locateValues[i];
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
let locator = await common.getLocator(
|
|
35
|
+
locateUsing,
|
|
36
|
+
locateValue
|
|
37
|
+
)
|
|
38
|
+
element = await browser.$(locator)
|
|
39
|
+
if (element) {
|
|
35
40
|
node.log += `Attempt ${i + 1}: Element found using ${using}: ${value}\n`;
|
|
36
41
|
locateUsing = using
|
|
37
42
|
locateValue = value
|
|
@@ -42,49 +47,40 @@ module.exports = function (RED) {
|
|
|
42
47
|
node.warn(`Element not found using ${using}: ${value}`);
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
|
-
if (!
|
|
50
|
+
if (!element) {
|
|
46
51
|
throw new Error(`Element not found using all selector values`);
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
if (config.check === 'clickable') {
|
|
51
56
|
node.log += `Check the webelement is clickable, identified using ${locateUsing}: "${locateValue}".`
|
|
52
|
-
msg.payload = await
|
|
57
|
+
msg.payload = await element.isClickable()
|
|
53
58
|
} else if (config.check === 'displayed') {
|
|
54
59
|
node.log += `Check the webelement is displayed, identified using ${locateUsing}: "${locateValue}".`
|
|
55
|
-
msg.payload = await
|
|
60
|
+
msg.payload = await element.isDisplayed()
|
|
56
61
|
} else if (config.check === 'displayedInView') {
|
|
57
62
|
node.log += `Check the webelement is displayed in view port, identified using ${locateUsing}: "${locateValue}".`
|
|
58
|
-
msg.payload = await
|
|
63
|
+
msg.payload = await element.isDisplayedInViewport()
|
|
59
64
|
} else if (config.check === 'enabled') {
|
|
60
65
|
node.log += `Check the webelement is enabled, identified using ${locateUsing}: "${locateValue}".`
|
|
61
|
-
msg.payload = await
|
|
66
|
+
msg.payload = await element.isEnabled()
|
|
62
67
|
} else if (config.check === 'existing') {
|
|
63
68
|
node.log += `Check the webelement is existing, identified using ${locateUsing}: "${locateValue}".`
|
|
64
|
-
msg.payload = await
|
|
69
|
+
msg.payload = await element.isExisting()
|
|
65
70
|
} else if (config.check === 'focused') {
|
|
66
71
|
node.log += `Check the webelement is focused, identified using ${locateUsing}: "${locateValue}".`
|
|
67
|
-
msg.payload = await
|
|
72
|
+
msg.payload = await element.isFocused()
|
|
68
73
|
} else if (config.check === 'selected') {
|
|
69
74
|
node.log += `Check the webelement is selected, identified using ${locateUsing}: "${locateValue}".`
|
|
70
|
-
msg.payload = await
|
|
75
|
+
msg.payload = await element.isSelected()
|
|
71
76
|
}
|
|
72
77
|
await common.log(node)
|
|
73
78
|
common.successStatus(node)
|
|
74
79
|
node.send(msg)
|
|
75
80
|
} catch (e) {
|
|
76
|
-
// if(e.message == 'unable to find'){
|
|
77
|
-
// msg.payload = false
|
|
78
|
-
// node.log = `Webelement is NOT displayed, identified using ${locateUsing}: "${locateValue}".`
|
|
79
|
-
// await common.log(node)
|
|
80
|
-
// common.successStatus(node)
|
|
81
|
-
// node.send(msg)
|
|
82
|
-
// }
|
|
83
|
-
// else{
|
|
84
81
|
await common.log(node)
|
|
85
82
|
common.handleError(e, node, msg)
|
|
86
83
|
}
|
|
87
|
-
//}
|
|
88
84
|
})
|
|
89
85
|
}
|
|
90
86
|
RED.nodes.registerType('element-check', elementCheck)
|
package/src/explicit-wait.html
CHANGED