@bucky24/jsbehave 0.12.2 → 0.12.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/README.md +2 -0
- package/package.json +2 -3
- package/src/index.js +22 -1
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,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bucky24/jsbehave",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"description": "A module that allows BDD testing for browser based testing in Selenium.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "node src/index.js examples/basic_example.behave",
|
|
8
8
|
"browserTest": "node src/index.js examples/browser_example.behave",
|
|
9
9
|
"screenshotTest": "node src/index.js examples/screenshot_example.behave",
|
|
10
|
-
"actionTest": "node src/index.js examples/action_example.behave"
|
|
11
|
-
"publish": "npm publish --access=public"
|
|
10
|
+
"actionTest": "node src/index.js examples/action_example.behave"
|
|
12
11
|
},
|
|
13
12
|
"repository": {
|
|
14
13
|
"type": "git",
|
package/src/index.js
CHANGED
|
@@ -379,13 +379,19 @@ function closeBrowserWithName([ name ]) {
|
|
|
379
379
|
async function compareContent([ selector, text ]) {
|
|
380
380
|
const sel = getSelector(selector);
|
|
381
381
|
const elem = await driver().findElement(sel);
|
|
382
|
-
text = getText(text);
|
|
382
|
+
text = getText(text, true);
|
|
383
383
|
const html = await elem.getAttribute('innerHTML');
|
|
384
|
+
if (text instanceof RegExp && text.test(html)) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
384
387
|
if (html === text) {
|
|
385
388
|
return;
|
|
386
389
|
}
|
|
387
390
|
|
|
388
391
|
const value = await elem.getAttribute('value');
|
|
392
|
+
if (text instanceof RegExp && text.test(value)) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
389
395
|
if (value === text) {
|
|
390
396
|
return;
|
|
391
397
|
}
|
|
@@ -452,6 +458,20 @@ async function windowSwitch(index) {
|
|
|
452
458
|
await driver().switchTo().window(handles[index]);
|
|
453
459
|
}
|
|
454
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
|
+
|
|
455
475
|
const startTestRegex = "\\[test (.+)\\]";
|
|
456
476
|
const startActionRegex = "\\[action (.+)\\]";
|
|
457
477
|
|
|
@@ -492,6 +512,7 @@ const operations = {
|
|
|
492
512
|
[startActionRegex]: startBlock,
|
|
493
513
|
"\\[endaction\\]": endBlock,
|
|
494
514
|
"switch to window (.+)": windowSwitch,
|
|
515
|
+
"read content from element (.+) into variable (.+)": readContentToVariable,
|
|
495
516
|
};
|
|
496
517
|
|
|
497
518
|
async function handleLines(lines) {
|