froth-webdriverio-framework 4.0.59 → 4.0.61

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.
@@ -47,6 +47,10 @@ let dismissAlert = null;
47
47
 
48
48
  let generateJWT=null;
49
49
 
50
+ let switchToWindowByTitle = null;
51
+ let switchToWindowByIndex = null;
52
+
53
+
50
54
  if (process.env.LOCATION ==null || process.env.LOCATION == 'local') {
51
55
  basepath = ".";
52
56
  } else {
@@ -61,7 +65,8 @@ 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;
@@ -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};
@@ -7,8 +7,16 @@ console.log('=====wdios common config===== ');
7
7
 
8
8
  // Select platform at runtime
9
9
  const PLATFORM = process.env.PLATFORM || 'browserstack';
10
- const configFile = process.env.YML_NAME || '../ymls/browserstack/android/android_caps.yml';
11
10
  console.log('====>PLATFORM:', PLATFORM);
11
+
12
+ const configFile = process.env.YML_NAME ;
13
+
14
+ const resultdetails = {
15
+ comments: [],
16
+ excution_status: null, // Pass/Fail
17
+ excution_time: null, // Execution time in milliseconds
18
+ };
19
+
12
20
  // Load YAML file
13
21
  //const capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
14
22
 
@@ -20,6 +28,7 @@ try {
20
28
  const errorMsg = `The capability file does not exist in the currently configured repository at path: ${path.resolve(process.cwd(), configFile)}: ${e.message},Please update the Capability by editing the file`;
21
29
  console.error(errorMsg);
22
30
  resultdetails.comments.push(errorMsg);
31
+ resultdetails.excution_status = 'FAIL';
23
32
 
24
33
  try {
25
34
  exeDetails.updateExecuitonDetails(
@@ -48,6 +57,7 @@ if (!SUITE_FILE || !fs.existsSync(SUITE_FILE)) {
48
57
 
49
58
  console.error(errorMsg);
50
59
  resultdetails.comments.push(errorMsg);
60
+ resultdetails.excution_status = 'FAIL';
51
61
 
52
62
  // Fire API call in background (non-blocking)
53
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "4.0.59",
3
+ "version": "4.0.61",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",