topological-nodered-wdio 0.4.2 → 0.4.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "topological-nodered-wdio",
3
3
  "description": "Open source WebdriverIO nodes for Node-RED",
4
- "version": "0.4.2",
4
+ "version": "0.4.4",
5
5
  "author": "topological",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -12,42 +12,50 @@ module.exports = function (RED) {
12
12
  let locateValue = config.locateValue || msg.locateValue
13
13
 
14
14
  let browser = await common.getBrowser(node.context())
15
-
16
- let element = await common.getElement(
15
+ let locator = await common.getLocator(
17
16
  browser,
18
17
  locateUsing,
19
18
  locateValue
20
- )
19
+ )
21
20
 
22
21
  if (config.check === 'clickable') {
23
22
  node.log = `Check the webelement is clickable, identified using ${locateUsing}: "${locateValue}".`
24
- msg.payload = await element.isClickable()
23
+ msg.payload = await browser.$(locator).isClickable()
25
24
  } else if (config.check === 'displayed') {
26
25
  node.log = `Check the webelement is displayed, identified using ${locateUsing}: "${locateValue}".`
27
- msg.payload = await element.isDisplayed()
26
+ msg.payload = await browser.$(locator).isDisplayed()
28
27
  } else if (config.check === 'displayedInView') {
29
28
  node.log = `Check the webelement is displayed in view port, identified using ${locateUsing}: "${locateValue}".`
30
- msg.payload = await element.isDisplayedInViewport()
29
+ msg.payload = await browser.$(locator).isDisplayedInViewport()
31
30
  } else if (config.check === 'enabled') {
32
31
  node.log = `Check the webelement is enabled, identified using ${locateUsing}: "${locateValue}".`
33
- msg.payload = await element.isEnabled()
32
+ msg.payload = await browser.$(locator).isEnabled()
34
33
  } else if (config.check === 'existing') {
35
34
  node.log = `Check the webelement is existing, identified using ${locateUsing}: "${locateValue}".`
36
- msg.payload = await element.isExisting()
35
+ msg.payload = await browser.$(locator).isExisting()
37
36
  } else if (config.check === 'focused') {
38
37
  node.log = `Check the webelement is focused, identified using ${locateUsing}: "${locateValue}".`
39
- msg.payload = await element.isFocused()
38
+ msg.payload = await browser.$(locator).isFocused()
40
39
  } else if (config.check === 'selected') {
41
40
  node.log = `Check the webelement is selected, identified using ${locateUsing}: "${locateValue}".`
42
- msg.payload = await element.isSelected()
41
+ msg.payload = await browser.$(locator).isSelected()
43
42
  }
44
43
  await common.log(node)
45
44
  common.successStatus(node)
46
45
  node.send(msg)
47
46
  } catch (e) {
48
- await common.log(node)
49
- common.handleError(e, node, msg)
50
- }
47
+ // if(e.message == 'unable to find'){
48
+ // msg.payload = false
49
+ // node.log = `Webelement is NOT displayed, identified using ${locateUsing}: "${locateValue}".`
50
+ // await common.log(node)
51
+ // common.successStatus(node)
52
+ // node.send(msg)
53
+ // }
54
+ // else{
55
+ await common.log(node)
56
+ common.handleError(e, node, msg)
57
+ }
58
+ //}
51
59
  })
52
60
  }
53
61
  RED.nodes.registerType('element-check', elementCheck)
@@ -12,7 +12,7 @@ module.exports = function(RED) {
12
12
  let locateValue = config.locateValue || msg.locateValue
13
13
 
14
14
  let browser = await common.getBrowser(node.context())
15
- let element = await common.getElement(
15
+ let locator = await common.getLocator(
16
16
  browser,
17
17
  locateUsing,
18
18
  locateValue
@@ -24,15 +24,15 @@ module.exports = function(RED) {
24
24
 
25
25
  if (config.action === 'displayed') {
26
26
  node.log = `Waiting for the element to be displayed for ${time}, identified using ${locateUsing}: "${locateValue}".`
27
- await element.waitForDisplayed({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
27
+ await browser.$(locator).waitForDisplayed({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
28
28
  } else if (config.action === 'enabled') {
29
29
  node.log = `Waiting for the element to be enabled for ${time}, identified using ${locateUsing}: "${locateValue}".`
30
- await element.waitForEnabled({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
30
+ await browser.$(locator).waitForEnabled({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
31
31
  } else if (config.action === 'exists') {
32
32
  node.log = `Waiting for the element to be exists for ${time}, identified using ${locateUsing}: "${locateValue}".`
33
- await element.waitForExist({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
33
+ await browser.$(locator).waitForExist({timeout: time, reverse: reverse, timeoutMsg: error, interval : 2000})
34
34
  } else if (config.action === 'until') {
35
- await element.waitUntil()
35
+ await browser.$(locator).waitUntil()
36
36
  }
37
37
 
38
38
  await common.log(node)
@@ -70,7 +70,7 @@ module.exports.getElementId = async (browser, using, value) => {
70
70
  return elementId
71
71
  }
72
72
 
73
- module.exports.getElement = async (browser, using, value) => {
73
+ module.exports.getLocator = async (browser, using, value) => {
74
74
  let locator = ''
75
75
  switch (using) {
76
76
  case 'id':
@@ -101,8 +101,7 @@ module.exports.getElement = async (browser, using, value) => {
101
101
  locator = value
102
102
  }
103
103
 
104
- element = await browser.$(locator)
105
- return element
104
+ return locator
106
105
  }
107
106
 
108
107
  module.exports.handleError = (e, node, msg) => {