Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
fix(dom-utils): fix eslint issues and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
astappiev committed Sep 2, 2019
1 parent cb07d25 commit 6d23ead
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions packages/dom-utils/lib/DomCapture.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const axios = require('axios');
const { URL } = require('url');

const { ArgumentGuard, Location, GeneralUtils, PerformanceUtils } = require('@applitools/eyes-common');
const { ArgumentGuard, Location, GeneralUtils, PerformanceUtils, EyesError } = require('@applitools/eyes-common');
const { getCaptureDomAndPollScript } = require('@applitools/dom-capture');

const DomCaptureReturnType = {
Expand All @@ -18,6 +18,7 @@ const SCRIPT_RESPONSE_STATUS = {
};

const DOM_EXTRACTION_TIMEOUT = 5 * 60 * 1000;
const DOM_CAPTURE_PULL_TIMEOUT = 200; // ms
const DOCUMENT_LOCATION_HREF_SCRIPT = 'return document.location.href';

/**
Expand Down Expand Up @@ -88,15 +89,15 @@ class DomCapture {
do {
const resultAsString = await this._driver.executeScript(script);
result = JSON.parse(resultAsString);
await this._driver.sleep(200);
await GeneralUtils.sleep(DOM_CAPTURE_PULL_TIMEOUT);
} while (result.status === SCRIPT_RESPONSE_STATUS.WIP && !isCheckTimerTimedOut);

if (result.status === SCRIPT_RESPONSE_STATUS.ERROR) {
throw new Error(`DomCapture Error: ${result.error}`);
throw new EyesError('Error during capturing DOM', result.error);
}

if (isCheckTimerTimedOut) {
throw new Error('DomCapture Timed out');
throw new EyesError('DomCapture Timed out');
}

const domSnapshotRawArr = result && result.value ? result.value.split('\n') : [];
Expand Down Expand Up @@ -143,7 +144,7 @@ class DomCapture {

const locationAfterSwitch = await this.getLocation();
if (locationAfterSwitch === originLocation) {
this._logger.verbose('Switching to frame failed');
this._logger.log('Switching to frame failed');
domIFrame = {};
} else {
domIFrame = await this.getFrameDom(script, url);
Expand Down
2 changes: 1 addition & 1 deletion packages/dom-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"main": "./index.js",
"dependencies": {
"@applitools/dom-capture": "^7.0.15",
"@applitools/dom-capture": "^7.0.17",
"@applitools/eyes-common": "^3.9.1",
"axios": "^0.19.0"
},
Expand Down
Loading

0 comments on commit 6d23ead

Please sign in to comment.