froth-webdriverio-framework 4.0.60 → 4.0.62
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.
|
@@ -45,9 +45,13 @@ let selectDropDownValue = null;
|
|
|
45
45
|
let acceptAlert = null;
|
|
46
46
|
let dismissAlert = null;
|
|
47
47
|
|
|
48
|
-
let generateJWT=null;
|
|
48
|
+
let generateJWT = null;
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
let switchToWindowByTitle = null;
|
|
51
|
+
let switchToWindowByIndex = null;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if (process.env.LOCATION == null || process.env.LOCATION == 'local') {
|
|
51
55
|
basepath = ".";
|
|
52
56
|
} else {
|
|
53
57
|
basepath = "froth-webdriverio-framework/froth_common_actions";
|
|
@@ -61,18 +65,19 @@ scrollDownToView = require(basepath + '/scroll').scrollDownToView;
|
|
|
61
65
|
scrollRightToView = require(basepath + '/scroll').scrollRightToView;
|
|
62
66
|
scrollIntoView = require(basepath + '/scroll').scrollIntoView;
|
|
63
67
|
scrollUpUntilVisible = require(basepath + '/scroll').scrollupUntilVisible;
|
|
64
|
-
|
|
68
|
+
switchToWindowByTitle = require(basepath + '/swicthWindowTab').switch2WindowByTitle;
|
|
69
|
+
switchToWindowByIndex = require(basepath + '/swicthWindowTab').switch2WindowByIndex;
|
|
65
70
|
|
|
66
71
|
swipeDown = require(basepath + '/swipe').swipedown;
|
|
67
72
|
swipeLeft = require(basepath + '/swipe').swipeleft;
|
|
68
73
|
swipeRight = require(basepath + '/swipe').swiperight;
|
|
69
74
|
swipeUp = require(basepath + '/swipe').swipeup;
|
|
70
|
-
swipetoFit= require(basepath + '/swipe').swipetofit;
|
|
75
|
+
swipetoFit = require(basepath + '/swipe').swipetofit;
|
|
71
76
|
swipeWithCoordinates = require(basepath + '/swipe').swipewithcoordinates;
|
|
72
77
|
|
|
73
78
|
clickIfVisible = require(basepath + "/click").clickIfVisible;
|
|
74
79
|
clickByIdWithExecute = require(basepath + "/click").clickByIdWithExecute;
|
|
75
|
-
doubleClick= require(basepath + "/click").doubleclick;
|
|
80
|
+
doubleClick = require(basepath + "/click").doubleclick;
|
|
76
81
|
|
|
77
82
|
assertText = require(basepath + '/assert').assertText;
|
|
78
83
|
assertAttributeValue = require(basepath + '/assert').assertAttributeValue;
|
|
@@ -84,8 +89,8 @@ randomint = require(basepath + '/random').RNDINT;
|
|
|
84
89
|
randomalphanum = require(basepath + '/random').RNDALPHANUM;
|
|
85
90
|
randomdecimal = require(basepath + '/random').RNDDECIMAL;
|
|
86
91
|
randomregex = require(basepath + '/random').RNDREGEX;
|
|
87
|
-
random= require(basepath + '/random').RANDOM;
|
|
88
|
-
randomdate= require(basepath + '/random').RNDDATE;
|
|
92
|
+
random = require(basepath + '/random').RANDOM;
|
|
93
|
+
randomdate = require(basepath + '/random').RNDDATE;
|
|
89
94
|
|
|
90
95
|
storetext = require(basepath + '/storeToBuffer').STORETEXT;
|
|
91
96
|
storevalue = require(basepath + '/storeToBuffer').STOREVALUE;
|
|
@@ -139,5 +144,7 @@ module.exports = {
|
|
|
139
144
|
swipeUp,
|
|
140
145
|
swipetoFit,
|
|
141
146
|
swipeWithCoordinates,
|
|
142
|
-
generateJWT
|
|
147
|
+
generateJWT,
|
|
148
|
+
switchToWindowByTitle,
|
|
149
|
+
switchToWindowByIndex
|
|
143
150
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Switches to a browser window/tab by its title using WebdriverIO.
|
|
3
|
+
* @param {string} title - The title of the window/tab to switch to.
|
|
4
|
+
*/
|
|
5
|
+
async function switch2WindowByTitle(title) {
|
|
6
|
+
const handles = await browser.getWindowHandles();
|
|
7
|
+
for (const handle of handles) {
|
|
8
|
+
await browser.switchToWindow(handle);
|
|
9
|
+
const currentTitle = await browser.getTitle();
|
|
10
|
+
if (currentTitle === title) {
|
|
11
|
+
return true; // Switched successfully
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
throw new Error(`No window with title "${title}" found.`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Switches to a browser window/tab by its index using WebdriverIO.
|
|
19
|
+
* @param {number} index - The index of the window/tab to switch to (0-based).
|
|
20
|
+
*/
|
|
21
|
+
async function switch2WindowByIndex(index) {
|
|
22
|
+
const handles = await browser.getWindowHandles();
|
|
23
|
+
if (index < 0 || index >= handles.length) {
|
|
24
|
+
throw new Error(`Invalid window index: ${index}. There are only ${handles.length} windows open.`);
|
|
25
|
+
}
|
|
26
|
+
await browser.switchToWindow(handles[index]);
|
|
27
|
+
return true; // Switched successfully
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// Example usage in a test
|
|
32
|
+
// await switchToWindowByTitle('Your Window Title');
|
|
33
|
+
module.exports = {switch2WindowByTitle,switch2WindowByIndex};
|