froth-webdriverio-framework 7.0.17 → 7.0.19

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.
Files changed (35) hide show
  1. package/froth_common_actions_back/Utils.js +167 -0
  2. package/froth_common_actions_back/alert.js +49 -0
  3. package/froth_common_actions_back/apicall.js +179 -0
  4. package/froth_common_actions_back/assert.js +85 -0
  5. package/froth_common_actions_back/captureNavigationTime.js +53 -0
  6. package/froth_common_actions_back/click.js +57 -0
  7. package/froth_common_actions_back/dropDown.js +34 -0
  8. package/froth_common_actions_back/emailParsing.js +161 -0
  9. package/froth_common_actions_back/jwt.js +64 -0
  10. package/froth_common_actions_back/logData.js +73 -0
  11. package/froth_common_actions_back/random.js +230 -0
  12. package/froth_common_actions_back/scroll.js +104 -0
  13. package/froth_common_actions_back/storeToBuffer.js +45 -0
  14. package/froth_common_actions_back/swicthWindowTab.js +36 -0
  15. package/froth_common_actions_back/swipe.js +219 -0
  16. package/froth_configs/commonhook.js +1 -1
  17. package/froth_configs_back/commonconfig.js +409 -0
  18. package/froth_configs_back/setallDatailinBuffer.js +100 -0
  19. package/froth_configs_back/wdio.common.conf.js +53 -0
  20. package/froth_configs_back/wdio.common.conf_back.js +138 -0
  21. package/package.json +36 -22
  22. package/browserstack.err +0 -1
  23. package/buffer_storage/FROTHE_SUITE_DETAILS +0 -1
  24. package/buffer_storage/FROTH_EXECUTION_ID +0 -1
  25. package/buffer_storage/FROTH_LOGIN_TOKEN +0 -1
  26. package/buffer_storage/FROTH_TOTAL_DURATION +0 -1
  27. package/buffer_storage/ORGANISATION_DOMAIN_URL +0 -1
  28. package/froth_configs/commonhook copy.js +0 -38
  29. package/froth_configs/commonhook_with_old_code.js +0 -425
  30. package/froth_configs/wdio.common.conf copy.js +0 -57
  31. package/local.log +0 -8
  32. package/log/key-metrics.json +0 -4853
  33. package/log/sdk-cli-debug.log +0 -122
  34. package/log/sdk-cli.log +0 -16974
  35. package/log/sdk-debug-utility.log +0 -0
@@ -0,0 +1,100 @@
1
+ const getLoginToken = require("../froth_api_calls/loginapi");
2
+ const exeDetails = require("../froth_api_calls/getexecutionDetails")
3
+ //const getintegrationdetails = require("../froth_api_calls/getintegrationDetails");
4
+ const getSuiteDetails = require("../froth_api_calls/getsuiteDetails");
5
+ const getDataById = require("../froth_api_calls/readTestdata");
6
+
7
+ async function generateBuildNumber() {
8
+ try {
9
+ const now = await new Date();
10
+ const timestamp = await formatDate(now); // Format date as needed
11
+
12
+ // Construct the build number with timestamp and counter
13
+ const buildNumber = `${timestamp}`;
14
+ process.env.BUILD_NUMBER = buildNumber;
15
+ console.log("Generated Build Number:", buildNumber);
16
+ // Increment the counter for the next build
17
+ } catch (error) {
18
+ console.log("error in generateBuildNumber")
19
+ }
20
+ //return buildNumber;
21
+ }
22
+
23
+ async function formatDate(date) {
24
+ const year = await date.getFullYear();
25
+ const month = await padZero(date.getMonth() + 1); // Month is zero-indexed
26
+ const day = await padZero(date.getDate());
27
+ const hours = await padZero(date.getHours());
28
+ const minutes = await padZero(date.getMinutes());
29
+ const seconds =await padZero(date.getSeconds());
30
+
31
+ return `${year}${month}${day}_${hours}${minutes}${seconds}`;
32
+ }
33
+
34
+ async function padZero(num) {
35
+ return await num.toString().padStart(2, '0');
36
+ }
37
+
38
+ async function setEnvVariables() {
39
+ await generateBuildNumber();
40
+ await BUFFER.setItem("FROTH_TOTAL_DURATION", 0);
41
+ await BUFFER.setItem("FROTH_EXECUTION_ID", process.env.EXECUTION_ID || 1);
42
+ await BUFFER.setItem("ORGANISATION_DOMAIN_URL", process.env.ORGANISATION_DOMAIN_URL || "https://devapi.frothtestops.com");
43
+ await BUFFER.setItem("FROTH_LOGIN_TOKEN", process.env.API_TOKEN)
44
+ console.log("api token in set evn variable :" + BUFFER.getItem("FROTH_LOGIN_TOKEN"))
45
+ console.log("CICD_RUN_ID in set evn variable :" + process.env.CICD_RUN_ID)
46
+ }
47
+
48
+ async function setLoginToken() {
49
+ try {
50
+
51
+ const getToken = await getLoginToken(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD"));
52
+ process.env.FROTH_LOGIN_TOKEN = getToken;
53
+ BUFFER.setItem("FROTH_LOGIN_TOKEN", getToken)
54
+
55
+ } catch (error) {
56
+ // console.error('Error in main function:', error);
57
+ }
58
+ }
59
+
60
+ async function setExecutionDetails() {
61
+ try {
62
+ const getExeDetails = await exeDetails.getExecuitonDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), BUFFER.getItem("FROTH_EXECUTION_ID"));
63
+ process.env.AUTOMATION_SUITE_ID = getExeDetails.automation_suite_id;
64
+ process.env.BROWSERSTACK_LOCAL = getExeDetails.browser_stack_local;
65
+ process.env.BROWSERSTACK_APP_PATH = getExeDetails.app_url;
66
+ process.env.MEDIA_FILES = JSON.stringify(getExeDetails.mediaurls);
67
+ console.log("Execution Details:", JSON.stringify(getExeDetails));
68
+
69
+ } catch (error) {
70
+ // console.error('Error in main function:', error);
71
+ }
72
+ }
73
+
74
+
75
+ async function setSuiteDetails() {
76
+ try {
77
+ const getSuiteDetail = await getSuiteDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), process.env.AUTOMATION_SUITE_ID);
78
+ BUFFER.setItem("FROTHE_SUITE_DETAILS", JSON.stringify(getSuiteDetail.script_details))
79
+ process.env.TESTDATA_ID = getSuiteDetail.test_data_id;
80
+ return getSuiteDetail;
81
+
82
+ } catch (error) {
83
+ // console.error('Error in main function:', error);
84
+ }
85
+ }
86
+ async function setTestDataDetails() {
87
+ try {
88
+ const jsonobject = await getDataById(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("FROTH_LOGIN_TOKEN"), process.env.TESTDATA_ID);
89
+
90
+ } catch (error) {
91
+ // console.error('Error in main function:', error);
92
+ }
93
+ }
94
+ module.exports = {
95
+ setEnvVariables,
96
+ setLoginToken,
97
+ setExecutionDetails,
98
+ setSuiteDetails,
99
+ setTestDataDetails
100
+ };
@@ -0,0 +1,53 @@
1
+ const deepmerge = require('deepmerge')
2
+ const path = require('path');
3
+ const commonconfig = require('./commonconfig');
4
+ const SUITE_FILE = path.resolve(process.cwd(), process.env.SUITE);
5
+ console.log('====>SUITE_FILE:', SUITE_FILE);
6
+
7
+
8
+ exports.config = deepmerge(commonconfig, {
9
+ user: 'naveen_OSt3Pw',
10
+ key: 'B9Rx28MTKFzRJ2QEVK1c',
11
+ services: [
12
+ [
13
+ 'browserstack',
14
+ {
15
+ browserstackLocal: false,
16
+ buildIdentifier: '#${BUILD_NUMBER}',
17
+ opts: {
18
+ forcelocal: false,
19
+ localIdentifier: 'webdriverio-browserstack-repo'
20
+ }
21
+ },
22
+ ],
23
+ ],
24
+
25
+ capabilities: [
26
+ {
27
+ browserName: 'chrome',
28
+ browserVersion: 'latest',
29
+ 'bstack:options': {
30
+ buildName: 'browserstack build',
31
+ source: 'webdriverio:sample-master:v1.2'
32
+ }
33
+ },
34
+ ],
35
+
36
+ updateJob: false,
37
+ specs: require(SUITE_FILE).tests,
38
+ exclude: [],
39
+
40
+ logLevel: 'info',
41
+ coloredLogs: true,
42
+ screenshotPath: './errorShots/',
43
+ baseUrl: '',
44
+ waitforTimeout: 10000,
45
+ connectionRetryTimeout: 90000,
46
+ connectionRetryCount: 3,
47
+
48
+ framework: 'mocha',
49
+ mochaOpts: {
50
+ ui: 'bdd',
51
+ timeout: 20000
52
+ }
53
+ });
@@ -0,0 +1,138 @@
1
+ const deepmerge = require('deepmerge')
2
+ const fs = require('fs');
3
+ const yaml = require('js-yaml');
4
+ const path = require('path');
5
+ const commonconfig = require('./commonconfig');
6
+ console.log('=====wdios common config===== ');
7
+
8
+ // Select platform at runtime
9
+ const PLATFORM = process.env.PLATFORM || 'browserstack';
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
+
20
+ // Load YAML file
21
+ //const capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
22
+
23
+ let capabilities;
24
+
25
+ try {
26
+ capabilities = yaml.load(fs.readFileSync(path.join(path.resolve(process.cwd(), configFile)), 'utf8'));
27
+ // Merge chrome-specific options if applicable
28
+
29
+ } catch (e) {
30
+ 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`;
31
+ console.error(errorMsg);
32
+ resultdetails.comments.push(errorMsg);
33
+ resultdetails.excution_status = 'FAIL';
34
+
35
+ try {
36
+ exeDetails.updateExecuitonDetails(
37
+ process.env.ORGANISATION_DOMAIN_URL,
38
+ process.env.API_TOKEN,
39
+ process.env.EXECUTION_ID,
40
+ resultdetails
41
+ );
42
+ setTimeout(() => {
43
+ console.log("30 seconds passed.");
44
+ // You can call your API or exit the process here
45
+ }, 30000);
46
+ console.log('Execution details updated successfully.');
47
+ } catch (err) {
48
+ console.error('Failed to update execution details:', err.message);
49
+ }
50
+ process.exit(1);
51
+ }
52
+ console.log('====>capabilities:', capabilities);
53
+
54
+ const SUITE_FILE = path.resolve(process.cwd(), process.env.SUITE);
55
+ console.log('====>SUITE_FILE:', SUITE_FILE);
56
+
57
+ if (!SUITE_FILE || !fs.existsSync(SUITE_FILE)) {
58
+ let errorMsg = `The suite file does not exist in the currently configured repository at path: ${SUITE_FILE}. Please update the SUITE by editing the file`;
59
+
60
+ console.error(errorMsg);
61
+ resultdetails.comments.push(errorMsg);
62
+ resultdetails.excution_status = 'FAIL';
63
+
64
+ // Fire API call in background (non-blocking)
65
+
66
+ try {
67
+ exeDetails.updateExecuitonDetails(
68
+ process.env.ORGANISATION_DOMAIN_URL,
69
+ process.env.API_TOKEN,
70
+ process.env.EXECUTION_ID,
71
+ resultdetails
72
+ );
73
+ setTimeout(() => {
74
+ console.log("30 seconds passed.");
75
+ // You can call your API or exit the process here
76
+ }, 30000);
77
+ console.log('Execution details updated successfully.');
78
+ } catch (err) {
79
+ console.error('Failed to update execution details:', err.message);
80
+ }
81
+ process.exit(1);
82
+ }
83
+
84
+ function setupPrerequisites() {
85
+ console.log("inside this fuction first ");
86
+ if (PLATFORM === 'browserstack') {
87
+ process.env.BROWSERSTACK_USERNAME = capabilities.userName;
88
+ capabilities.accessKey = Buffer.from(capabilities.accessKey, 'base64').toString('utf-8');
89
+ process.env.BROWSERSTACK_ACCESS_KEY = capabilities.accessKey
90
+
91
+ console.log('capabilities.platformName:', capabilities.platformName ?? 'web');
92
+ process.env.BS_SESSION_TYPE = capabilities.platformName === 'android' || capabilities.platformName === 'ios' ? 'app-automate' : 'automate';
93
+ capabilities.buildName = process.env.FROTH_TESTOPS_BUILD_NAME;
94
+
95
+ }
96
+
97
+ }
98
+
99
+ const specificConfig = setupPrerequisites();
100
+
101
+
102
+ exports.config = deepmerge(commonconfig,
103
+
104
+ {
105
+ user: process.env.BROWSERSTACK_USERNAME,
106
+ key: process.env.BROWSERSTACK_ACCESS_KEY,
107
+ // debug: true,
108
+ // execArgv: ['--inspect-brk'],
109
+ services: PLATFORM === 'browserstack'
110
+ ? ['browserstack']
111
+ : PLATFORM === 'saucelabs'
112
+ ? ['sauce']
113
+ : [],
114
+
115
+ //runner: 'local',
116
+ specs: require(SUITE_FILE).tests,
117
+
118
+ maxInstances: 1,
119
+ capabilities: [capabilities],
120
+
121
+ logLevel: 'info',
122
+ coloredLogs: true,
123
+ screenshotPath: './errorShots/',
124
+ bail: 0,
125
+ //baseUrl: 'https://example.com',
126
+ waitforTimeout: 90000,
127
+ connectionRetryTimeout: 90000,
128
+ connectionRetryCount: 3,
129
+
130
+ framework: 'mocha',
131
+ reporters: ['spec'],
132
+ maxInstances: 10,
133
+ updateJob: false,
134
+ mochaOpts: {
135
+ ui: 'bdd',
136
+ timeout: 300000
137
+ }
138
+ });
package/package.json CHANGED
@@ -1,39 +1,53 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "7.0.17",
4
- "readme": "WendriverIO Integration with [BrowserStack](https://www.browserstack.com)",
5
- "description": "Selenium examples for WebdriverIO and BrowserStack App Automate",
3
+ "version": "7.0.19",
4
+ "readme": "WebdriverIO Integration",
5
+ "description": "WebdriverIO and BrowserStack App Automate",
6
+ "license": "MIT",
6
7
  "scripts": {
7
- "wdio": "wdio run ./wdio.conf.js"
8
+ "wdio:ios": "npx wdio ./ios.conf.js",
9
+ "wdio:android": "npx wdio ./android.conf.js",
10
+ "wdio:web": "npx wdio ./web.conf.js",
11
+ "wdio:webbs": "npx wdio ./web.conf.bs.js",
12
+ "wdio:ios:local": "npx wdio ./ios.local.conf.js",
13
+ "android:generate-allure-report": "allure generate ./mobile/androidReports/allure-results --clean && allure open",
14
+ "ios:generate-allure-report": "allure generate ./mobile/iosReports/allure-results --clean && allure open",
15
+ "web:generate-allure-report": "allure generate ./webReports/allure-results --clean && allure open",
16
+ "lint": "eslint ."
8
17
  },
9
18
  "repository": {
10
19
  "type": "git",
11
- "url": "git+https://github.com/browserstack/webdriverio-appium-app-browserstack.git"
20
+ "url": "https://github.com/RoboticoDigitalProjects/froth-webdriverio.git"
12
21
  },
13
22
  "keywords": [
14
23
  "webdriverio",
15
24
  "browserstack",
16
- "appium",
17
- "tests"
25
+ "appium"
18
26
  ],
19
- "bugs": {
20
- "url": "https://github.com/browserstack/webdriverio-appium-app-browserstack/issues"
21
- },
22
- "homepage": "https://github.com/browserstack/webdriverio-appium-app-browserstack#readme",
23
27
  "dependencies": {
24
- "@wdio/appium-service": "^9.21.0",
25
- "@wdio/browserstack-service": "^9.21.0",
26
- "@wdio/cli": "^9.21.1",
27
- "@wdio/local-runner": "^9.21.0",
28
- "@wdio/mocha-framework": "^9.21.0",
29
- "@wdio/spec-reporter": "^9.20.0",
30
- "appium": "^3.1.2",
31
- "appium-uiautomator2-driver": "^6.7.1",
32
- "chai": "^4.3.6",
28
+ "@wdio/appium-service": "^9.0.9",
29
+ "@wdio/browserstack-service": "^9.0.9",
30
+ "@wdio/cli": "^9.0.9",
31
+ "@wdio/local-runner": "^9.0.9",
32
+ "@wdio/mocha-framework": "^8.36.1",
33
+ "@wdio/spec-reporter": "^8.36.1",
34
+ "appium": "^2.15.0",
35
+ "appium-uiautomator2-driver": "^4.0.1",
36
+ "assert": "^2.1.0",
37
+ "axios": "^1.7.7",
38
+ "browserstack-local": "^1.5.5",
39
+ "chai": "^5.1.1",
33
40
  "crypto-js": "^4.2.0",
34
41
  "deepmerge": "^4.3.1",
42
+ "express": "^5.1.0",
43
+ "form-data": "^4.0.0",
44
+ "fs": "^0.0.1-security",
45
+ "js-yaml": "^4.1.1",
46
+ "mysql2": "^3.10.2",
47
+ "node-fetch": "^3.3.2",
35
48
  "node-localstorage": "^3.0.5",
36
49
  "randexp": "^0.5.3",
37
- "webdriverio": "^9"
50
+ "ts-node": "^10.9.2",
51
+ "typescript": "^5.4.5"
38
52
  }
39
- }
53
+ }
package/browserstack.err DELETED
@@ -1 +0,0 @@
1
- [object Object]
@@ -1 +0,0 @@
1
- undefined
@@ -1 +0,0 @@
1
- 2472
@@ -1 +0,0 @@
1
- eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzY1MzUzNTY3LCJpYXQiOjE3NjUzNDk5NjcsImp0aSI6IjZhOTQ2MDdkYjU1ZDQ4MDRiYTQ5OTk0NTQwOGJhMDZhIiwidXNlcl9pZCI6MX0.N5zPsGN5PUeiB3DV9bGHDKySdNT6uD_2OX1O4PEho6o
@@ -1 +0,0 @@
1
- 0
@@ -1 +0,0 @@
1
- https://api.frothtestops.com
@@ -1,38 +0,0 @@
1
-
2
- const setAllDetails = require('./setallDatailinBuffer');
3
- let getExeDetails;
4
- module.exports = {
5
- onPrepare: async () => {
6
- console.log('==== ON PREPARE HOOK ====');
7
- await setAllDetails.setEnvVariables();
8
- await setAllDetails.setExecutionDetails();
9
- await setAllDetails.setSuiteDetails();
10
- await setAllDetails.setTestDataDetails();
11
-
12
- console.log('✅ App & media set in on prepare');
13
- },
14
-
15
- beforeSession: async function (config, capabilities, specs) {
16
- try {
17
- if (process.env.BS_SESSION_TYPE === 'app-automate') {
18
- console.log("inside before session")
19
- if (capabilities['bstack:options']) {
20
- console.log("inside before session if block")
21
-
22
- capabilities['bstack:options'].app = process.env.BROWSERSTACK_APP_PATH;
23
- }
24
- capabilities['appium:app'] = process.env.BROWSERSTACK_APP_PATH;
25
- console.log('✅ App & media set in before session');
26
-
27
- }
28
- console.log('final cinfig dteials :' + JSON.stringify(capabilities))
29
-
30
- console.log("config details " + JSON.stringify(config))
31
-
32
-
33
- } catch (error) {
34
- console.error('🚨 Error in beforeSession:', error);
35
- console.error('🚨 Error in beforeSession:', error.message);
36
- }
37
- }
38
- };