froth-webdriverio-framework 5.0.3 → 5.0.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.
|
@@ -51,6 +51,7 @@ let generateJWT = null;
|
|
|
51
51
|
let switchToWindowByTitle = null;
|
|
52
52
|
let switchToWindowByIndex = null;
|
|
53
53
|
|
|
54
|
+
let captureLoadNavigation = null;
|
|
54
55
|
|
|
55
56
|
if (process.env.LOCATION == null || process.env.LOCATION == 'local') {
|
|
56
57
|
basepath = ".";
|
|
@@ -107,7 +108,7 @@ acceptAlert = require(basepath + '/alert.js').acceptalert;
|
|
|
107
108
|
dismissAlert = require(basepath + '/alert.js').dismissalert;
|
|
108
109
|
|
|
109
110
|
generateJWT = require(basepath + '/jwt').generateJWTToken;
|
|
110
|
-
|
|
111
|
+
captureLoadNavigation= require(basepath + '/captureNavigationTime').captureLoadNavigationTime;
|
|
111
112
|
//export the variabels
|
|
112
113
|
module.exports = {
|
|
113
114
|
scrollToEnd,
|
|
@@ -149,5 +150,6 @@ module.exports = {
|
|
|
149
150
|
swipeWithCoordinates,
|
|
150
151
|
generateJWT,
|
|
151
152
|
switchToWindowByTitle,
|
|
152
|
-
switchToWindowByIndex
|
|
153
|
+
switchToWindowByIndex,
|
|
154
|
+
captureLoadNavigation
|
|
153
155
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Function to verify text in Android app
|
|
2
2
|
import assert from 'assert';
|
|
3
|
+
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
3
4
|
|
|
4
5
|
async function assertText(elementSelector, expectedText) {
|
|
5
6
|
|
|
@@ -70,15 +71,15 @@ async function assertAttributeValue(elementSelector, attributeName, expectedText
|
|
|
70
71
|
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
async function amendToBrowserstack(annotationMessage, level) {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
// async function amendToBrowserstack(annotationMessage, level) {
|
|
75
|
+
// try {
|
|
76
|
+
// await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
78
|
+
// } catch (error) {
|
|
79
|
+
// console.error('Error occurred while annoting into BS', error);
|
|
80
|
+
// throw error;
|
|
81
|
+
// }
|
|
82
|
+
// }
|
|
82
83
|
module.exports = { assertText, assertAttributeValue };
|
|
83
84
|
|
|
84
85
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Capture Navigation / Page Load time
|
|
6
|
+
* @param {string} pageName - (Optional) Custom name for the page
|
|
7
|
+
*/
|
|
8
|
+
async function captureLoadNavigationTime(pageName = '') {
|
|
9
|
+
try {
|
|
10
|
+
// Try modern API first
|
|
11
|
+
let perfEntries = await browser.execute(() => {
|
|
12
|
+
if (performance.getEntriesByType) {
|
|
13
|
+
const [nav] = performance.getEntriesByType('navigation');
|
|
14
|
+
return nav ? nav.toJSON() : null;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
});
|
|
18
|
+
let pageLoadTime;
|
|
19
|
+
|
|
20
|
+
if (perfEntries && perfEntries.loadEventEnd) {
|
|
21
|
+
pageLoadTime = perfEntries.loadEventEnd;
|
|
22
|
+
} else {
|
|
23
|
+
// Fallback to old API
|
|
24
|
+
const perfTiming = await browser.execute(() => JSON.stringify(window.performance.timing));
|
|
25
|
+
const timing = JSON.parse(perfTiming);
|
|
26
|
+
pageLoadTime = timing.loadEventEnd - timing.navigationStart;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// If no custom name passed, use the page title
|
|
30
|
+
let title = pageName || await browser.getTitle();
|
|
31
|
+
|
|
32
|
+
// Clean title: remove special characters, keep words separated by space
|
|
33
|
+
title = title
|
|
34
|
+
.replace(/[^a-zA-Z0-9]+/g, ' ') // replace non-alphanumeric with space
|
|
35
|
+
.replace(/\s+/g, ' ') // collapse multiple spaces
|
|
36
|
+
.trim(); // remove leading/trailing spaces
|
|
37
|
+
|
|
38
|
+
// const pageLoadTime = perfEntries.loadEventEnd; // Already relative to startTime
|
|
39
|
+
await amendToBrowserstack(`⏱ Page Load Time for ${title}: ${pageLoadTime} ms`, "info");
|
|
40
|
+
|
|
41
|
+
console.log(`⏱ Page Load Time for ${title}: ${pageLoadTime} ms`);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('Error capturing navigation timing:', error);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
module.exports = { captureLoadNavigationTime };
|
|
50
|
+
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
2
|
+
|
|
1
3
|
async function select4mDropDownValue(elementSelector, selectOption) {
|
|
2
4
|
try {
|
|
3
5
|
// let selectBox = await $(elementSelector);
|
|
@@ -20,13 +22,13 @@ async function select4mDropDownText(elementSelector, visibleText) {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
async function amendToBrowserstack(annotationMessage, level) {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
// async function amendToBrowserstack(annotationMessage, level) {
|
|
26
|
+
// try {
|
|
27
|
+
// await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
29
|
+
// } catch (error) {
|
|
30
|
+
// console.error('Error occurred while verifying text:', error);
|
|
31
|
+
// // throw error;
|
|
32
|
+
// }
|
|
33
|
+
// }
|
|
32
34
|
module.exports = { select4mDropDownValue,select4mDropDownText };
|