@applitools/nml-client 1.0.1 → 1.0.2
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/dist/broker.js +17 -12
- package/dist/client.js +30 -10
- package/package.json +3 -3
- package/types/broker.d.ts +0 -1
- package/types/client.d.ts +2 -2
- package/dist/app.js +0 -42
- package/types/app.d.ts +0 -1
package/dist/broker.js
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.broker = exports.
|
|
3
|
+
exports.broker = exports.publishMessageRequest = void 0;
|
|
4
4
|
const req_1 = require("@applitools/req");
|
|
5
5
|
async function publishMessageRequest(options) {
|
|
6
|
-
const response = await (0, req_1.req)(options.url, {
|
|
6
|
+
const response = await (0, req_1.req)(options.url, {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
body: options.payload,
|
|
9
|
+
headers: { 'Content-Type': 'application/json' },
|
|
10
|
+
hooks: {
|
|
11
|
+
afterResponse: async (response) => {
|
|
12
|
+
if (response.response.status != 200)
|
|
13
|
+
return;
|
|
14
|
+
return (0, req_1.req)(options.url + '-response', {
|
|
15
|
+
retry: [{ statuses: [404] }],
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
7
20
|
if (response.status !== 200) {
|
|
8
21
|
throw new Error(`something went wrong when communicating with the mobile application, please try running your test again (error code: ${response.status})`);
|
|
9
22
|
}
|
|
10
23
|
return response;
|
|
11
24
|
}
|
|
12
25
|
exports.publishMessageRequest = publishMessageRequest;
|
|
13
|
-
async function pollForMessageResult(url) {
|
|
14
|
-
url = /-response$/.test(url) ? url : url + '-response';
|
|
15
|
-
return (0, req_1.req)(url, {
|
|
16
|
-
retry: [{ statuses: [404] }],
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
exports.pollForMessageResult = pollForMessageResult;
|
|
20
26
|
async function broker(url, request) {
|
|
21
|
-
await publishMessageRequest({
|
|
27
|
+
const response = await publishMessageRequest({
|
|
22
28
|
url,
|
|
23
29
|
payload: request,
|
|
24
30
|
});
|
|
25
|
-
const response = await pollForMessageResult(url);
|
|
26
31
|
const { payload } = await response.json();
|
|
27
|
-
if (payload.error)
|
|
32
|
+
if (!payload || (payload && payload.error))
|
|
28
33
|
throw new Error(`There was a problem when interacting with the mobile application. The provided error message was "${payload.error.message}" and had a stack trace of "${payload.error.stack}"`);
|
|
29
34
|
return payload.result;
|
|
30
35
|
}
|
package/dist/client.js
CHANGED
|
@@ -1,30 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.takeSnapshot = exports.takeScreenshot = void 0;
|
|
4
|
-
const app_1 = require("./app");
|
|
5
27
|
const broker_1 = require("./broker");
|
|
6
|
-
const
|
|
7
|
-
async function takeScreenshot(
|
|
8
|
-
const url = await (0, app_1.getBrokerURL)(driver);
|
|
28
|
+
const utils = __importStar(require("@applitools/utils"));
|
|
29
|
+
async function takeScreenshot(url, options) {
|
|
9
30
|
const request = {
|
|
10
31
|
protocolVersion: '1.0',
|
|
11
32
|
name: 'TAKE_SCREENSHOT',
|
|
12
|
-
key:
|
|
33
|
+
key: utils.general.guid(),
|
|
13
34
|
payload: options,
|
|
14
35
|
};
|
|
15
36
|
const { screenshotURL } = await (0, broker_1.broker)(url, request);
|
|
16
37
|
return screenshotURL;
|
|
17
38
|
}
|
|
18
39
|
exports.takeScreenshot = takeScreenshot;
|
|
19
|
-
async function takeSnapshot(
|
|
20
|
-
const url = await (0, app_1.getBrokerURL)(driver);
|
|
40
|
+
async function takeSnapshot(url, options) {
|
|
21
41
|
const request = {
|
|
22
42
|
protocolVersion: '1.0',
|
|
23
43
|
name: 'TAKE_SNAPSHOT',
|
|
24
|
-
key:
|
|
44
|
+
key: utils.general.guid(),
|
|
25
45
|
payload: options,
|
|
26
46
|
};
|
|
27
|
-
const
|
|
28
|
-
return
|
|
47
|
+
const result = await (0, broker_1.broker)(url, request);
|
|
48
|
+
return result;
|
|
29
49
|
}
|
|
30
50
|
exports.takeSnapshot = takeSnapshot;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/nml-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Client to integrate the SDKs to the Native Mobile Library (NML)",
|
|
5
5
|
"homepage": "https://applitools.com",
|
|
6
6
|
"bugs": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@applitools/bongo": "^2.1.6",
|
|
53
53
|
"@applitools/scripts": "^1.1.0",
|
|
54
54
|
"@applitools/spec-driver-selenium": "^1.3.17",
|
|
55
|
-
"@applitools/test-utils": "^1.
|
|
55
|
+
"@applitools/test-utils": "^1.5.1",
|
|
56
56
|
"@types/mocha": "^9.1.1",
|
|
57
57
|
"@types/node": "12",
|
|
58
58
|
"@types/selenium-webdriver": "^4.1.2",
|
|
@@ -72,6 +72,6 @@
|
|
|
72
72
|
"typescript": "^4.6.4"
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
|
-
"node": ">=
|
|
75
|
+
"node": ">=14.0.0"
|
|
76
76
|
}
|
|
77
77
|
}
|
package/types/broker.d.ts
CHANGED
package/types/client.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ScreenshotSettings, SnapshotSettings } from './broker';
|
|
2
|
-
export declare function takeScreenshot(
|
|
3
|
-
export declare function takeSnapshot(
|
|
2
|
+
export declare function takeScreenshot(url: any, options?: ScreenshotSettings): Promise<string>;
|
|
3
|
+
export declare function takeSnapshot(url: string, options?: SnapshotSettings): Promise<any>;
|
package/dist/app.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getBrokerURL = void 0;
|
|
27
|
-
const utils = __importStar(require("@applitools/utils"));
|
|
28
|
-
async function getBrokerURL(driver) {
|
|
29
|
-
console.log(driver);
|
|
30
|
-
const selector = `//XCUIElementTypeOther[@name="Applitools_View"]`;
|
|
31
|
-
let element;
|
|
32
|
-
if (utils.types.has(driver, 'element'))
|
|
33
|
-
element = driver && await driver.element({ type: 'xpath', selector });
|
|
34
|
-
else if (utils.types.has(driver, 'findElement')) {
|
|
35
|
-
element = driver && await driver.findElement({ xpath: selector });
|
|
36
|
-
}
|
|
37
|
-
const result = JSON.parse(await element.getText());
|
|
38
|
-
if (result.error)
|
|
39
|
-
throw new Error(result.error);
|
|
40
|
-
return result.nextPath;
|
|
41
|
-
}
|
|
42
|
-
exports.getBrokerURL = getBrokerURL;
|
package/types/app.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getBrokerURL(driver: any): Promise<any>;
|