froth-webdriverio-framework 5.0.3 → 5.0.5
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,8 @@ let generateJWT = null;
|
|
|
51
51
|
let switchToWindowByTitle = null;
|
|
52
52
|
let switchToWindowByIndex = null;
|
|
53
53
|
|
|
54
|
+
let captureLoadNavigation = null;
|
|
55
|
+
let amendBrowserStackLog = null;
|
|
54
56
|
|
|
55
57
|
if (process.env.LOCATION == null || process.env.LOCATION == 'local') {
|
|
56
58
|
basepath = ".";
|
|
@@ -107,7 +109,9 @@ acceptAlert = require(basepath + '/alert.js').acceptalert;
|
|
|
107
109
|
dismissAlert = require(basepath + '/alert.js').dismissalert;
|
|
108
110
|
|
|
109
111
|
generateJWT = require(basepath + '/jwt').generateJWTToken;
|
|
112
|
+
captureLoadNavigation= require(basepath + '/captureNavigationTime').captureLoadNavigationTime;
|
|
110
113
|
|
|
114
|
+
amendBrowserStackLog= require(basepath + '../froth_api_calls/browsersatckSessionInfo').amend2Browserstack;
|
|
111
115
|
//export the variabels
|
|
112
116
|
module.exports = {
|
|
113
117
|
scrollToEnd,
|
|
@@ -149,5 +153,7 @@ module.exports = {
|
|
|
149
153
|
swipeWithCoordinates,
|
|
150
154
|
generateJWT,
|
|
151
155
|
switchToWindowByTitle,
|
|
152
|
-
switchToWindowByIndex
|
|
156
|
+
switchToWindowByIndex,
|
|
157
|
+
captureLoadNavigation,
|
|
158
|
+
amendBrowserStackLog
|
|
153
159
|
};
|
|
@@ -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,52 @@
|
|
|
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
|
+
let pageLoadTime;
|
|
10
|
+
try {
|
|
11
|
+
// Try modern API first
|
|
12
|
+
let perfEntries = await browser.execute(() => {
|
|
13
|
+
if (performance.getEntriesByType) {
|
|
14
|
+
const [nav] = performance.getEntriesByType('navigation');
|
|
15
|
+
return nav ? nav.toJSON() : null;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if (perfEntries && perfEntries.loadEventEnd) {
|
|
22
|
+
pageLoadTime = perfEntries.loadEventEnd;
|
|
23
|
+
} else {
|
|
24
|
+
// Fallback to old API
|
|
25
|
+
const perfTiming = await browser.execute(() => JSON.stringify(window.performance.timing));
|
|
26
|
+
const timing = JSON.parse(perfTiming);
|
|
27
|
+
pageLoadTime = timing.loadEventEnd - timing.navigationStart;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// If no custom name passed, use the page title
|
|
31
|
+
let title = pageName || await browser.getTitle();
|
|
32
|
+
|
|
33
|
+
// Clean title: remove special characters, keep words separated by space
|
|
34
|
+
title = title
|
|
35
|
+
.replace(/[^a-zA-Z0-9]+/g, ' ') // replace non-alphanumeric with space
|
|
36
|
+
.replace(/\s+/g, ' ') // collapse multiple spaces
|
|
37
|
+
.trim(); // remove leading/trailing spaces
|
|
38
|
+
|
|
39
|
+
pageLoadTime = perfEntries.loadEventEnd; // Already relative to startTime
|
|
40
|
+
await amendToBrowserstack(`⏱ Page Load Time for ${title}: ${pageLoadTime} ms`, "info");
|
|
41
|
+
|
|
42
|
+
console.log(`⏱ Page Load Time for ${title}: ${pageLoadTime} ms`);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('Error capturing navigation timing:', error);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return pageLoadTime;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
module.exports = { captureLoadNavigationTime };
|
|
52
|
+
|
|
@@ -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 };
|