@bucky24/jsbehave 0.12.3 → 0.12.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/README.md CHANGED
@@ -69,6 +69,8 @@ Running `jsbehave` directly will locate all files that end in `.behave` and will
69
69
 
70
70
  `switch to window <index>` switches context to the window handle at the index (useful for popups)
71
71
 
72
+ `read content from element <selector> into variable <variable name>` Takes the value or inner html from the element and stores it in the given variable
73
+
72
74
  ## Tests
73
75
 
74
76
  The operations `[test <name>]` and `[endtest]` indicate a test block.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bucky24/jsbehave",
3
- "version": "0.12.3",
3
+ "version": "0.12.5",
4
4
  "description": "A module that allows BDD testing for browser based testing in Selenium.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -210,12 +210,12 @@ async function waitForText([ selector, text ]) {
210
210
  const sel = getSelector(selector);
211
211
  const elem = await driver().findElement(sel);
212
212
  text = getText(text);
213
- if (elem.text === text) {
213
+ if (elem.text.includes(text)) {
214
214
  return;
215
215
  }
216
216
 
217
217
  const value = await elem.getAttribute("value")
218
- if (value === text) {
218
+ if (value.includes(text)) {
219
219
  return;
220
220
  }
221
221
 
@@ -384,7 +384,7 @@ async function compareContent([ selector, text ]) {
384
384
  if (text instanceof RegExp && text.test(html)) {
385
385
  return;
386
386
  }
387
- if (html === text) {
387
+ if (html.includes(text)) {
388
388
  return;
389
389
  }
390
390
 
@@ -392,7 +392,7 @@ async function compareContent([ selector, text ]) {
392
392
  if (text instanceof RegExp && text.test(value)) {
393
393
  return;
394
394
  }
395
- if (value === text) {
395
+ if (value.includes(text)) {
396
396
  return;
397
397
  }
398
398
 
@@ -458,6 +458,20 @@ async function windowSwitch(index) {
458
458
  await driver().switchTo().window(handles[index]);
459
459
  }
460
460
 
461
+ async function readContentToVariable([selector, varName]) {
462
+ const sel = getSelector(selector);
463
+
464
+ const elem = await driver().findElement(sel);
465
+ const value = await elem.getAttribute('value');
466
+ if (value) {
467
+ setVariable(varName, value);
468
+ return;
469
+ }
470
+ const html = await elem.getAttribute('innerHTML');
471
+
472
+ setVariable(varName, html);
473
+ }
474
+
461
475
  const startTestRegex = "\\[test (.+)\\]";
462
476
  const startActionRegex = "\\[action (.+)\\]";
463
477
 
@@ -498,6 +512,7 @@ const operations = {
498
512
  [startActionRegex]: startBlock,
499
513
  "\\[endaction\\]": endBlock,
500
514
  "switch to window (.+)": windowSwitch,
515
+ "read content from element (.+) into variable (.+)": readContentToVariable,
501
516
  };
502
517
 
503
518
  async function handleLines(lines) {