topological-nodered-wdio 0.4.3 → 0.4.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 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.3",
4
+ "version": "0.4.5",
5
5
  "author": "topological",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -33,10 +33,10 @@
33
33
  inputs: 1,
34
34
  outputs: 1,
35
35
  icon: 'white-globe.png',
36
- label: function() {
36
+ label: function () {
37
37
  return this.name || 'dropdown action'
38
38
  },
39
- oneditprepare: function() {
39
+ oneditprepare: function () {
40
40
  setDropdownAction()
41
41
  }
42
42
  })
@@ -46,10 +46,14 @@
46
46
  <div class="form-row">
47
47
  <label for="node-input-locateUsing"><i class="fa fa-tasks"></i> Locate Method</label>
48
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="selector">Jquery Selector</option>
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>
53
57
  </select>
54
58
  </div>
55
59
  <div class="form-row">
@@ -118,4 +122,4 @@
118
122
  <li>Get Value</li>
119
123
  </ul>
120
124
  </p>
121
- </script>
125
+ </script>
@@ -12,11 +12,12 @@ 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
19
19
  )
20
+ let element = await browser.$(locator)
20
21
 
21
22
  let text = config.text || msg.text
22
23
  let attribute = config.attribute || msg.attribute
@@ -12,52 +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
- )
21
- await element.waitForDisplayed({timeout: 10000, reverse: false, timeoutMsg: 'unable to find', interval : 2000})
19
+ )
22
20
 
23
21
  if (config.check === 'clickable') {
24
22
  node.log = `Check the webelement is clickable, identified using ${locateUsing}: "${locateValue}".`
25
- msg.payload = await element.isClickable()
23
+ msg.payload = await browser.$(locator).isClickable()
26
24
  } else if (config.check === 'displayed') {
27
25
  node.log = `Check the webelement is displayed, identified using ${locateUsing}: "${locateValue}".`
28
- msg.payload = await element.isDisplayed()
26
+ msg.payload = await browser.$(locator).isDisplayed()
29
27
  } else if (config.check === 'displayedInView') {
30
28
  node.log = `Check the webelement is displayed in view port, identified using ${locateUsing}: "${locateValue}".`
31
- msg.payload = await element.isDisplayedInViewport()
29
+ msg.payload = await browser.$(locator).isDisplayedInViewport()
32
30
  } else if (config.check === 'enabled') {
33
31
  node.log = `Check the webelement is enabled, identified using ${locateUsing}: "${locateValue}".`
34
- msg.payload = await element.isEnabled()
32
+ msg.payload = await browser.$(locator).isEnabled()
35
33
  } else if (config.check === 'existing') {
36
34
  node.log = `Check the webelement is existing, identified using ${locateUsing}: "${locateValue}".`
37
- msg.payload = await element.isExisting()
35
+ msg.payload = await browser.$(locator).isExisting()
38
36
  } else if (config.check === 'focused') {
39
37
  node.log = `Check the webelement is focused, identified using ${locateUsing}: "${locateValue}".`
40
- msg.payload = await element.isFocused()
38
+ msg.payload = await browser.$(locator).isFocused()
41
39
  } else if (config.check === 'selected') {
42
40
  node.log = `Check the webelement is selected, identified using ${locateUsing}: "${locateValue}".`
43
- msg.payload = await element.isSelected()
41
+ msg.payload = await browser.$(locator).isSelected()
44
42
  }
45
43
  await common.log(node)
46
44
  common.successStatus(node)
47
45
  node.send(msg)
48
46
  } catch (e) {
49
- if(e.message == 'unable to find'){
50
- msg.payload = false
51
- node.log = `Webelement is NOT displayed, identified using ${locateUsing}: "${locateValue}".`
52
- await common.log(node)
53
- common.successStatus(node)
54
- node.send(msg)
55
- }
56
- else{
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{
57
55
  await common.log(node)
58
56
  common.handleError(e, node, msg)
59
57
  }
60
- }
58
+ //}
61
59
  })
62
60
  }
63
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) => {