@bucky24/jsbehave 0.12.6 → 0.12.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +10 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bucky24/jsbehave",
3
- "version": "0.12.6",
3
+ "version": "0.12.8",
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
@@ -444,7 +444,13 @@ async function clickElementWithOffset([ selector, x, y ]) {
444
444
 
445
445
  async function takeScreenshot(test) {
446
446
  const activeBrowser = getVariable("jsbehave.active_driver");
447
- const image = await driver().takeScreenshot();
447
+ const activeDriver = await driver();
448
+ if (!activeDriver) {
449
+ // don't throw, we get here when an error happens so we're already handling a problem
450
+ console.error(`Unable to take screenshot - driver does not exist`);
451
+ return;
452
+ }
453
+ const image = activeDriver.takeScreenshot();
448
454
  const useTest = test.replace(/ /g, "_");
449
455
  let configPath = getVariable("screenshotDirectory");
450
456
  const fileName = `test_${useTest}_failure_${activeBrowser}.png`;
@@ -528,7 +534,8 @@ const operations = {
528
534
  };
529
535
 
530
536
  async function handleLines(lines) {
531
- for (let line of lines) {
537
+ for (let i=0;i<lines.length;i++) {
538
+ const line = lines[i];
532
539
  if (line === "") {
533
540
  continue;
534
541
  }
@@ -566,7 +573,7 @@ async function handleLines(lines) {
566
573
  const test = variables["jsbehave.activeBlock"];
567
574
  if (test) {
568
575
  console.log(`Test ${test} - FAILURE`);
569
- console.log(`Failure when running line "${line}" for "${operation}"`);
576
+ console.log(`Failed on line ${i+1}: "${line}" for "${operation}"`);
570
577
  console.log(error);
571
578
  const screenshotOnFailure = getVariable("screenshotOnFailure") === 'true';
572
579
  if (screenshotOnFailure) {