froth-webdriverio-framework 3.0.113 → 3.0.114
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.
- package/.github/workflows/main.yml +23 -0
- package/{froth_api_calls → api}/browsersatckSessionInfo.js +4 -8
- package/{froth_api_calls → api}/getexecutionDetails.js +27 -40
- package/{froth_api_calls → api}/getsuiteDetails.js +13 -14
- package/{froth_api_calls → api}/loginapi.js +4 -2
- package/{froth_api_calls → api}/readTestdata.js +4 -6
- package/{froth_common_actions → commonMethods}/Utils.js +9 -21
- package/{froth_common_actions → commonMethods}/alert.js +3 -3
- package/{froth_common_actions → commonMethods}/apicall.js +5 -17
- package/{froth_common_actions → commonMethods}/click.js +1 -24
- package/{froth_common_actions → commonMethods}/jwt.js +1 -1
- package/{froth_common_actions → commonMethods}/scroll.js +1 -23
- package/commonMethods/swipe.js +59 -0
- package/config/android.conf.js +49 -0
- package/config/api.conf.bs.js +76 -0
- package/config/api.conf.js +77 -0
- package/config/common.mobile.conf.js +45 -0
- package/{froth_configs → config}/commonconfig.js +45 -58
- package/config/injectimage.js +4 -0
- package/config/ios.conf.js +47 -0
- package/{froth_configs → config}/setallDatailinBuffer.js +16 -19
- package/config/web.conf.bs.js +76 -0
- package/config/web.conf.js +70 -0
- package/package.json +6 -5
- package/froth_common_actions/swipe.js +0 -219
- package/froth_configs/wdio.common.conf.js +0 -74
- /package/{froth_api_calls → api}/aesEncryption.js +0 -0
- /package/{froth_common_actions → commonMethods}/assert.js +0 -0
- /package/{froth_common_actions → commonMethods}/dropDown.js +0 -0
- /package/{froth_common_actions → commonMethods}/random.js +0 -0
- /package/{froth_common_actions → commonMethods}/storeToBuffer.js +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: npm_package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
release:
|
|
8
|
+
name: release
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- name: Checkout code
|
|
12
|
+
uses: actions/checkout@v2
|
|
13
|
+
- name: Setup Node.js
|
|
14
|
+
uses: actions/setup-node@v2
|
|
15
|
+
with:
|
|
16
|
+
node-version: '12.x'
|
|
17
|
+
registry-url: https://registry.npmjs.org
|
|
18
|
+
|
|
19
|
+
- name: Publish to npm
|
|
20
|
+
run: npm publish --access public
|
|
21
|
+
env:
|
|
22
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
|
|
23
|
+
|
|
@@ -5,13 +5,12 @@ async function getBSBuildDetails(sessiontype, bs_username, bs_pwd) {
|
|
|
5
5
|
console.log("sessiontype:" + sessiontype)
|
|
6
6
|
const username = bs_username;
|
|
7
7
|
const accessKey = bs_pwd;
|
|
8
|
-
console.log("accessKey:" + accessKey)
|
|
9
8
|
const basicAuth = btoa(`${username}:${accessKey}`);
|
|
10
9
|
|
|
11
10
|
let hashed_id = null;
|
|
12
11
|
|
|
13
12
|
// const sessionid= BUFFER.getItem("SESSION_ID");
|
|
14
|
-
|
|
13
|
+
|
|
15
14
|
const url = `https://api.browserstack.com/${sessiontype}/builds.json?name=${process.env.BROWSERSTACK_BUILD_NAME}`;
|
|
16
15
|
|
|
17
16
|
console.log("url:" + url)
|
|
@@ -36,7 +35,6 @@ async function getBSBuildDetails(sessiontype, bs_username, bs_pwd) {
|
|
|
36
35
|
} else {
|
|
37
36
|
const errorText = await response.text();
|
|
38
37
|
console.error(`Data fetch failed response in getBSBuildDetails:${response.status}`);
|
|
39
|
-
// console.error(`Data fetch failed response in getBSBuildDetails:${errorText}`);
|
|
40
38
|
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
41
39
|
}
|
|
42
40
|
|
|
@@ -54,9 +52,7 @@ async function getBSSessionDetails(sessiontype, bs_username, bs_pwd) {
|
|
|
54
52
|
try {
|
|
55
53
|
// const sessionId = sessionIdd;
|
|
56
54
|
const username = bs_username;
|
|
57
|
-
|
|
58
|
-
const accessKey = bs_pwd;
|
|
59
|
-
|
|
55
|
+
const accessKey = Buffer.from(bs_pwd, 'base64').toString('utf-8');
|
|
60
56
|
const basicAuth = btoa(`${username}:${accessKey}`);
|
|
61
57
|
|
|
62
58
|
const hash_id = await getBSBuildDetails(sessiontype, bs_username, accessKey)
|
|
@@ -81,7 +77,7 @@ async function getBSSessionDetails(sessiontype, bs_username, bs_pwd) {
|
|
|
81
77
|
const duration = data[0].automation_session.duration;
|
|
82
78
|
BUFFER.setItem("REPORT_URL", publicUrl)
|
|
83
79
|
BUFFER.setItem("FROTH_TOTAL_DURATION", duration)
|
|
84
|
-
|
|
80
|
+
|
|
85
81
|
//return jsondata;
|
|
86
82
|
} else if (response.status === 401) { //
|
|
87
83
|
console.log("Unauthorized, token expired")
|
|
@@ -106,7 +102,7 @@ async function amend2Browserstack(annotationMessage, level) {
|
|
|
106
102
|
try {
|
|
107
103
|
|
|
108
104
|
console.log("Annotation message inside amend2Browserstack:" + annotationMessage)
|
|
109
|
-
if (process.env.
|
|
105
|
+
if (process.env.BROWSERSTACK)
|
|
110
106
|
await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
111
107
|
|
|
112
108
|
} catch (error) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
const getLoginToken = require("../api/loginapi.js")
|
|
3
3
|
// Function to get data from the API using the Bearer token
|
|
4
4
|
|
|
5
5
|
async function getExecuitonDetails(frothUrl, token, id) {
|
|
@@ -21,24 +21,20 @@ async function getExecuitonDetails(frothUrl, token, id) {
|
|
|
21
21
|
if (response.ok) {
|
|
22
22
|
const data = await response.json();
|
|
23
23
|
// console.log(data)
|
|
24
|
-
jsondata.automation_suite_id = data.
|
|
25
|
-
jsondata.test_cycle_id = data.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//console.log("
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
console.log("in get execution details json data :" + JSON.stringify(jsondata));
|
|
24
|
+
jsondata.automation_suite_id = data.automation_suite_id;
|
|
25
|
+
jsondata.test_cycle_id = data.test_cycle_id;
|
|
26
|
+
if (data.testcycle_type === "Android" || data.testcycle_type === "Ios") {
|
|
27
|
+
jsondata.device_name = data.device_name
|
|
28
|
+
jsondata.version = data.version
|
|
29
|
+
}
|
|
30
|
+
// console.log("json data :" + JSON.stringify(jsondata));
|
|
34
31
|
|
|
35
32
|
return jsondata;
|
|
36
33
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
37
34
|
// Call login function to obtain a new token
|
|
38
|
-
|
|
35
|
+
const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
39
36
|
// Retry the request with the new token
|
|
40
|
-
|
|
41
|
-
console.log("Unauthorized, token expired"+response.status)
|
|
37
|
+
return getExecuitonDetails(frothUrl, newToken, id);
|
|
42
38
|
} else {
|
|
43
39
|
const errorText = await response.text();
|
|
44
40
|
console.error(`Data fetch failed response in getExecuitonDetails: ${response.status}`);
|
|
@@ -57,7 +53,7 @@ async function getExecuitonDetails(frothUrl, token, id) {
|
|
|
57
53
|
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_id,
|
|
56
|
+
async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_id,script_platform) {
|
|
61
57
|
let id;
|
|
62
58
|
const url = `${frothUrl}/api/execution-script-mapping/?execution_id=${execution_id}&automation_script_id=${script_id}&platform=${script_platform}`;
|
|
63
59
|
|
|
@@ -81,12 +77,10 @@ async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_i
|
|
|
81
77
|
|
|
82
78
|
return id;
|
|
83
79
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
84
|
-
console.log("Unauthorized, token expired"+response.status)
|
|
85
|
-
|
|
86
80
|
// Call login function to obtain a new token
|
|
87
|
-
|
|
81
|
+
const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
88
82
|
// Retry the request with the new token
|
|
89
|
-
|
|
83
|
+
return getExecuitonScriptDetails(frothUrl, newToken, execution_id, script_id);
|
|
90
84
|
} else {
|
|
91
85
|
const errorText = await response.text();
|
|
92
86
|
console.error(`Data fetch failed response in getExecuitonScriptDetails: ${response.status}`);
|
|
@@ -103,7 +97,7 @@ async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_i
|
|
|
103
97
|
}
|
|
104
98
|
|
|
105
99
|
async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
106
|
-
|
|
100
|
+
if (id != 0) {
|
|
107
101
|
|
|
108
102
|
|
|
109
103
|
const url = `${frothUrl}/api/test-execution-update/${id}/`;
|
|
@@ -119,11 +113,9 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
119
113
|
}
|
|
120
114
|
formData.append('id', BUFFER.getItem("FROTH_EXECUTION_ID"))
|
|
121
115
|
formData.append('report_url', BUFFER.getItem("REPORT_URL"))
|
|
122
|
-
formData.append('
|
|
116
|
+
formData.append('comments', JSON.stringify(resultdetails.comments))
|
|
123
117
|
|
|
124
118
|
console.log("Report URL:" + BUFFER.getItem("REPORT_URL"))
|
|
125
|
-
|
|
126
|
-
|
|
127
119
|
|
|
128
120
|
const response = await fetch(url, {
|
|
129
121
|
method: 'PUT',
|
|
@@ -140,11 +132,9 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
140
132
|
|
|
141
133
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
142
134
|
// Call login function to obtain a new token
|
|
143
|
-
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
console.log("Unauthorized, token expired"+response.status)
|
|
147
|
-
|
|
135
|
+
const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
136
|
+
// Retry the request with the new token
|
|
137
|
+
return updateExecuitonDetails(frothUrl, newToken, id, resultdetails);
|
|
148
138
|
} else {
|
|
149
139
|
const errorText = await response.text();
|
|
150
140
|
console.error(`error in updating the status into DB ${response.status}`);
|
|
@@ -157,18 +147,18 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
157
147
|
console.error('Error fetching data:', error);
|
|
158
148
|
|
|
159
149
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
150
|
+
} else {
|
|
151
|
+
console.error('Error fetching data: Invalid ID');
|
|
152
|
+
}
|
|
163
153
|
|
|
164
154
|
}
|
|
165
155
|
|
|
166
|
-
async function updateScriptExecutionStatus(frothUrl, token, scriptid,
|
|
156
|
+
async function updateScriptExecutionStatus(frothUrl, token, scriptid,script_platform, status) {
|
|
167
157
|
|
|
168
158
|
if (scriptid != 0) {
|
|
169
159
|
try {
|
|
170
|
-
console.log("script platform is "
|
|
171
|
-
const id = await getExecuitonScriptDetails(frothUrl, token, BUFFER.getItem("FROTH_EXECUTION_ID"), scriptid,
|
|
160
|
+
console.log("script platform is "+script_platform)
|
|
161
|
+
const id = await getExecuitonScriptDetails(frothUrl, token, BUFFER.getItem("FROTH_EXECUTION_ID"), scriptid,script_platform)
|
|
172
162
|
console.log("ID is :" + id)
|
|
173
163
|
const url = `${frothUrl}/api/script-status-percentage/${id}/`;
|
|
174
164
|
const formData = new FormData();
|
|
@@ -176,7 +166,6 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_pla
|
|
|
176
166
|
console.log("URL" + url)
|
|
177
167
|
// formData.append('execution_id', BUFFER.getItem("EXECUTION_ID"))
|
|
178
168
|
formData.append('script_status', status)
|
|
179
|
-
formData.append('updated_through_bot', true)
|
|
180
169
|
|
|
181
170
|
const response = await fetch(url, {
|
|
182
171
|
method: 'PUT',
|
|
@@ -193,11 +182,9 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_pla
|
|
|
193
182
|
|
|
194
183
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
195
184
|
// Call login function to obtain a new token
|
|
196
|
-
|
|
197
|
-
//
|
|
198
|
-
|
|
199
|
-
console.log("Unauthorized, token expired"+response.status)
|
|
200
|
-
|
|
185
|
+
const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
186
|
+
// Retry the request with the new token
|
|
187
|
+
return updateScriptExecutionStatus(frothUrl, newToken, scriptid,script_platform, status);
|
|
201
188
|
} else {
|
|
202
189
|
const errorText = await response.text();
|
|
203
190
|
console.error(`error in updating the status into DB ${response.status}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
const getLoginToken=require('./loginapi')
|
|
3
3
|
// Function to get data from the API using the Bearer token
|
|
4
4
|
async function getSuiteDetails(frothUrl, token, id) {
|
|
5
5
|
let jsondata = {};
|
|
@@ -18,38 +18,37 @@ async function getSuiteDetails(frothUrl, token, id) {
|
|
|
18
18
|
});
|
|
19
19
|
if (response.ok) {
|
|
20
20
|
const data = await response.json();
|
|
21
|
-
|
|
21
|
+
// console.log(data)
|
|
22
22
|
jsondata.automation_suite_id = data.id == null ? 0 : data.id;
|
|
23
23
|
jsondata.automation_suite_name = data.automation_suite_name == null ? "" : data.automation_suite_name;
|
|
24
24
|
jsondata.test_data_id = data.test_data_id == null ? 0 : data.test_data_id;
|
|
25
|
-
|
|
26
|
-
jsondata.script_details
|
|
27
|
-
|
|
25
|
+
jsondata.browser_stack_urls = data.browser_stack_urls == null ? "" : data.browser_stack_urls;
|
|
26
|
+
jsondata.script_details=data.script_details == null ? [] : data.script_details;
|
|
27
|
+
// console.log("automation_script_id:" + JSON.stringify(jsondata.automation_script_id))
|
|
28
28
|
const automationScripts = jsondata.script_details.reduce((obj, item) => {
|
|
29
29
|
obj[item.script_Id] = item.script_Id;
|
|
30
30
|
BUFFER.setItem(item.scriptName, item.scriptId);
|
|
31
|
-
BUFFER.setItem(item.scriptName
|
|
31
|
+
BUFFER.setItem(item.scriptName+"_PLATFORM", item.platform);
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
return obj;
|
|
34
34
|
}, {});
|
|
35
35
|
jsondata.test_sequence = data.test_sequence;
|
|
36
|
-
|
|
36
|
+
// console.log("automation_script_ details:" + JSON.stringify(BUFFER))
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
// console.log("json data :" + JSON.stringify(jsondata));
|
|
39
39
|
|
|
40
40
|
return jsondata;
|
|
41
41
|
|
|
42
42
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
43
43
|
// Call login function to obtain a new token
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
console.log("Unauthorized, token expired" + response.status)
|
|
44
|
+
const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
45
|
+
// Retry the request with the new token
|
|
46
|
+
return getSuiteDetails(frothUrl, newToken, id);
|
|
48
47
|
}
|
|
49
48
|
else {
|
|
50
49
|
const errorText = await response.text();
|
|
51
50
|
console.error(`Data fetch failed response in getSuiteDetails: ${response.status}`);
|
|
52
|
-
|
|
51
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
|
|
@@ -8,8 +8,10 @@ async function getLoginToken(frothUrl, email, password) {
|
|
|
8
8
|
console.log("URL: " + url);
|
|
9
9
|
const formData = new FormData();
|
|
10
10
|
formData.append('email_or_username', email);
|
|
11
|
-
formData.append('password', await enc(password,"froth-testops@rd"));
|
|
12
|
-
formData.append('
|
|
11
|
+
//formData.append('password', await enc(password,"froth-testops@rd"));
|
|
12
|
+
formData.append('password', password);
|
|
13
|
+
formData.append('is_ad_user', false);
|
|
14
|
+
formData.append('remember_me', false);
|
|
13
15
|
|
|
14
16
|
const response = await fetch(url, {
|
|
15
17
|
method: 'POST',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
const getLoginToken = require('
|
|
2
|
+
const getLoginToken = require('../api/loginapi.js');
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
// Function to get data from the API using the Bearer token
|
|
@@ -35,11 +35,9 @@ async function getDataById(frothUrl, token, id) {
|
|
|
35
35
|
}
|
|
36
36
|
else if (response.status === 401) { // Unauthorized, token expired
|
|
37
37
|
// Call login function to obtain a new token
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
console.log("Unauthorized, token expired" + response.status)
|
|
42
|
-
|
|
38
|
+
const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
39
|
+
// Retry the request with the new token
|
|
40
|
+
return getDataById(frothUrl, newToken, id);
|
|
43
41
|
}
|
|
44
42
|
else {
|
|
45
43
|
const errorText = await response.text();
|
|
@@ -7,17 +7,14 @@ let scrollToLeft = null;
|
|
|
7
7
|
let scrollToRight = null;
|
|
8
8
|
let scrollDownToView = null;
|
|
9
9
|
let scrollRightToView = null;
|
|
10
|
-
let scrollUpUntilVisible = null;
|
|
11
10
|
|
|
12
11
|
let swipeRight = null;
|
|
13
12
|
let swipeLeft = null;
|
|
14
13
|
let swipeUp = null;
|
|
15
14
|
let swipeDown = null;
|
|
16
|
-
|
|
17
|
-
let swipeWithCoordinates = null;
|
|
15
|
+
|
|
18
16
|
|
|
19
17
|
let clickIfVisible = null;
|
|
20
|
-
let doubleClick = null;
|
|
21
18
|
|
|
22
19
|
let assertText = null;
|
|
23
20
|
let randomtext = null;
|
|
@@ -38,15 +35,15 @@ let api = null;
|
|
|
38
35
|
|
|
39
36
|
let selectDropDownValue = null;
|
|
40
37
|
|
|
41
|
-
let
|
|
42
|
-
let
|
|
38
|
+
let acceptalert = null;
|
|
39
|
+
let dismissalert = null;
|
|
43
40
|
|
|
44
41
|
let generateJWT=null;
|
|
45
42
|
|
|
46
|
-
if (process.env.LOCATION ==
|
|
43
|
+
if (process.env.LOCATION == 'local') {
|
|
47
44
|
basepath = ".";
|
|
48
45
|
} else {
|
|
49
|
-
basepath = "froth-webdriverio-framework/
|
|
46
|
+
basepath = "froth-webdriverio-framework/commonMethods";
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
scrollToEnd = require(basepath + "/scroll").scrollToEnd;
|
|
@@ -56,19 +53,14 @@ scrollToRight = require(basepath + '/scroll').scrollToRight;
|
|
|
56
53
|
scrollDownToView = require(basepath + '/scroll').scrollDownToView;
|
|
57
54
|
scrollRightToView = require(basepath + '/scroll').scrollRightToView;
|
|
58
55
|
scrollIntoView = require(basepath + '/scroll').scrollIntoView;
|
|
59
|
-
scrollUpUntilVisible = require(basepath + '/scroll').scrollupUntilVisible;
|
|
60
|
-
|
|
61
56
|
|
|
62
57
|
swipeDown = require(basepath + '/swipe').swipedown;
|
|
63
58
|
swipeLeft = require(basepath + '/swipe').swipeleft;
|
|
64
59
|
swipeRight = require(basepath + '/swipe').swiperight;
|
|
65
60
|
swipeUp = require(basepath + '/swipe').swipeup;
|
|
66
|
-
swipetoFit= require(basepath + '/swipe').swipetofit;
|
|
67
|
-
swipeWithCoordinates = require(basepath + '/swipe').swipewithcoordinates;
|
|
68
61
|
|
|
69
62
|
clickIfVisible = require(basepath + "/click").clickIfVisible;
|
|
70
63
|
clickByIdWithExecute = require(basepath + "/click").clickByIdWithExecute;
|
|
71
|
-
doubleClick= require(basepath + "/click").doubleclick;
|
|
72
64
|
|
|
73
65
|
assertText = require(basepath + '/assert').assertText;
|
|
74
66
|
assertAttributeValue = require(basepath + '/assert').assertAttributeValue;
|
|
@@ -90,8 +82,8 @@ validate = require(basepath + '/apicall').validate;
|
|
|
90
82
|
|
|
91
83
|
selectDropDownValue = require(basepath + '/dropDown').select4mDropDownValue;
|
|
92
84
|
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
acceptalert = require(basepath + '/alert.js').acceptAlert;
|
|
86
|
+
dismissalert = require(basepath + '/alert.js').dismissAlert;
|
|
95
87
|
|
|
96
88
|
generateJWT = require(basepath + '/jwt').generateJWTToken;
|
|
97
89
|
|
|
@@ -105,7 +97,6 @@ module.exports = {
|
|
|
105
97
|
scrollRightToView,
|
|
106
98
|
clickIfVisible,
|
|
107
99
|
clickByIdWithExecute,
|
|
108
|
-
doubleClick,
|
|
109
100
|
assertText,
|
|
110
101
|
assertAttributeValue,
|
|
111
102
|
randomtext,
|
|
@@ -119,17 +110,14 @@ module.exports = {
|
|
|
119
110
|
storevalue,
|
|
120
111
|
storeattributevalue,
|
|
121
112
|
scrollIntoView,
|
|
122
|
-
scrollUpUntilVisible,
|
|
123
113
|
api,
|
|
124
114
|
validate,
|
|
125
115
|
selectDropDownValue,
|
|
126
|
-
|
|
127
|
-
|
|
116
|
+
acceptalert,
|
|
117
|
+
dismissalert,
|
|
128
118
|
swipeLeft,
|
|
129
119
|
swipeRight,
|
|
130
120
|
swipeDown,
|
|
131
121
|
swipeUp,
|
|
132
|
-
swipetoFit,
|
|
133
|
-
swipeWithCoordinates,
|
|
134
122
|
generateJWT
|
|
135
123
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
async function
|
|
1
|
+
async function acceptAlert() {
|
|
2
2
|
|
|
3
3
|
try {
|
|
4
4
|
await browser.waitUntil(async () => {
|
|
@@ -14,7 +14,7 @@ async function acceptalert() {
|
|
|
14
14
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
async function
|
|
17
|
+
async function dismissAlert() {
|
|
18
18
|
try {
|
|
19
19
|
await browser.waitUntil(async () => {
|
|
20
20
|
return await browser.isAlertOpen();
|
|
@@ -31,4 +31,4 @@ async function dismissalert() {
|
|
|
31
31
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
module.exports = {
|
|
34
|
+
module.exports = { acceptAlert, dismissAlert };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const amendToBrowserstack = require("../
|
|
1
|
+
const amendToBrowserstack = require("../api/browsersatckSessionInfo").amend2Browserstack;
|
|
2
2
|
|
|
3
3
|
async function callapi(method, api_url, queryParams, payloaddetails, authentication, headers, attachments) {
|
|
4
4
|
let response;
|
|
@@ -88,14 +88,8 @@ async function validate(attribute_name, attribute, actionname, buffer, buffernam
|
|
|
88
88
|
await validateAttributeData(attribute_name, attribute, buffer, buffername_value, datatype);
|
|
89
89
|
} else if (actionname.toLowerCase() == "setbuffer") {
|
|
90
90
|
BUFFER.setItem(buffername_value, attribute);
|
|
91
|
-
let annotationMessage = `The vlaue has been stored in the buffer : ${buffername_value}.`;
|
|
92
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
93
|
-
|
|
94
91
|
} else if (actionname.toLowerCase() == "getbuffer") {
|
|
95
|
-
let annotationMessage = `The vlaue has been retrived from the buffer : ${buffername_value}.`;
|
|
96
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
97
92
|
return BUFFER.getItem(buffername_value);
|
|
98
|
-
|
|
99
93
|
}
|
|
100
94
|
// } catch (e) {
|
|
101
95
|
// console.error('Error in validate method:', e);
|
|
@@ -115,25 +109,19 @@ async function validateAttributeData(attribute_name, attribute, buffer, bufferna
|
|
|
115
109
|
valueToVerify = Number(valueToVerify);
|
|
116
110
|
} else if (datatype.toLowerCase() == "boolean") {
|
|
117
111
|
valueToVerify = Boolean(valueToVerify);
|
|
118
|
-
}else if (datatype.toLowerCase() == "float") {
|
|
119
|
-
valueToVerify = parseFloat(valueToVerify);
|
|
120
|
-
}else if (datatype.toLowerCase() == "double") {
|
|
121
|
-
valueToVerify = parseFloat(valueToVerify);
|
|
122
|
-
}else if (datatype.toLowerCase() == "string") {
|
|
123
|
-
valueToVerify = valueToVerify.toString();
|
|
124
112
|
}
|
|
125
113
|
|
|
126
114
|
expect(attribute).toBe(valueToVerify, `${attribute_name} --> Expected value: ${valueToVerify}, but got: ${attribute}`);
|
|
127
115
|
assertionStatus = true; // If assertion passes, set status to true
|
|
128
116
|
|
|
129
|
-
console.log(
|
|
130
|
-
let annotationMessage =
|
|
117
|
+
console.log("verification succeeded.");
|
|
118
|
+
let annotationMessage = `${attribute_name} - verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`;
|
|
131
119
|
await amendToBrowserstack(annotationMessage, "info");
|
|
132
120
|
|
|
133
121
|
} catch (e) {
|
|
134
122
|
console.error('Error in validateAttributeData:', e);
|
|
135
|
-
console.log(
|
|
136
|
-
let annotationMessage =
|
|
123
|
+
console.log(`${attribute_name} verification failed. Expected text: ${valueToVerify}.`);
|
|
124
|
+
let annotationMessage = `${attribute_name} - verification failed. Expected text: ${valueToVerify}.`;
|
|
137
125
|
await amendToBrowserstack(annotationMessage, "error");
|
|
138
126
|
|
|
139
127
|
throw e;
|
|
@@ -20,29 +20,6 @@ async function clickIfVisible(elementSelector) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
async function doubleclick(elementSelector) {
|
|
24
|
-
try {
|
|
25
|
-
let isDisplayed;
|
|
26
|
-
// Wait for the element to be visible
|
|
27
|
-
await driver.waitUntil(async () => {
|
|
28
|
-
console.log("Waiting for element to be visible");
|
|
29
|
-
const element = await $(elementSelector);
|
|
30
|
-
isDisplayed = await element.isDisplayed();
|
|
31
|
-
console.log("Element is displayed:", isDisplayed);
|
|
32
|
-
if (isDisplayed) {
|
|
33
|
-
// Get the actual text from the element
|
|
34
|
-
const element = await $(elementSelector);
|
|
35
|
-
await element.doubleClick();
|
|
36
|
-
console.log("Element is double clicked successfully.");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
}, { timeout: 30000 });
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error("Element not found or not visible within 30 seconds");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
23
|
|
|
47
24
|
async function clickByIdWithExecute(elementid) {
|
|
48
25
|
try {
|
|
@@ -54,4 +31,4 @@ async function clickByIdWithExecute(elementid) {
|
|
|
54
31
|
}
|
|
55
32
|
}
|
|
56
33
|
|
|
57
|
-
module.exports = { clickIfVisible, clickByIdWithExecute
|
|
34
|
+
module.exports = { clickIfVisible, clickByIdWithExecute };
|
|
@@ -79,26 +79,4 @@ async function scrollIntoView(element){
|
|
|
79
79
|
console.error(error.message);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
async function scrollupUntilVisible(selector) {
|
|
84
|
-
const element = await $(selector);
|
|
85
|
-
|
|
86
|
-
while (!(await element.isDisplayed())) {
|
|
87
|
-
await driver.performActions([
|
|
88
|
-
{
|
|
89
|
-
type: 'pointer',
|
|
90
|
-
id: 'finger1',
|
|
91
|
-
parameters: { pointerType: 'touch' },
|
|
92
|
-
actions: [
|
|
93
|
-
{ type: 'pointerMove', duration: 0, x: 200, y: 800 },
|
|
94
|
-
{ type: 'pointerDown', button: 0 },
|
|
95
|
-
{ type: 'pause', duration: 100 },
|
|
96
|
-
{ type: 'pointerMove', duration: 500, x: 200, y: 200 },
|
|
97
|
-
{ type: 'pointerUp', button: 0 }
|
|
98
|
-
]
|
|
99
|
-
}
|
|
100
|
-
]);
|
|
101
|
-
await browser.pause(500);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
module.exports = { scrollToEnd, scrollToLeft, scrollToBeginning, scrollRightToView, scrollDownToView, scrollToRight ,scrollIntoView,scrollupUntilVisible};
|
|
82
|
+
module.exports = { scrollToEnd, scrollToLeft, scrollToBeginning, scrollRightToView, scrollDownToView, scrollToRight ,scrollIntoView};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
async function swipeleft(selector, xoffset, speedinsec) {
|
|
2
|
+
try {
|
|
3
|
+
console.log('Swiping left');
|
|
4
|
+
|
|
5
|
+
if (xoffset == null) {
|
|
6
|
+
driver.swipeLeft(selector, speedinsec);
|
|
7
|
+
} else {
|
|
8
|
+
driver.swipeLeft(selector, xoffset, speedinsec);
|
|
9
|
+
}
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error(error.message);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function swiperight(selector, xoffset, speedinsec) {
|
|
17
|
+
try {
|
|
18
|
+
console.log('Swiping right');
|
|
19
|
+
|
|
20
|
+
if (xoffset == null) {
|
|
21
|
+
driver.swipeRight(selector, speedinsec);
|
|
22
|
+
} else {
|
|
23
|
+
driver.swipeRight(selector, xoffset, speedinsec);
|
|
24
|
+
}
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error(error.message);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function swipeup(selector, yoffset, speedinsec) {
|
|
32
|
+
try {
|
|
33
|
+
console.log('Swiping up');
|
|
34
|
+
|
|
35
|
+
if (yoffset == null) {
|
|
36
|
+
driver.swipeUp(selector, speedinsec);
|
|
37
|
+
} else {
|
|
38
|
+
driver.swipeUp(selector, yoffset, speedinsec);
|
|
39
|
+
}
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error(error.message);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function swipedown(selector, yoffset, speedinsec) {
|
|
46
|
+
try {
|
|
47
|
+
console.log('Swiping down');
|
|
48
|
+
|
|
49
|
+
if (yoffset == null) {
|
|
50
|
+
driver.swipeDown(selector, speedinsec);
|
|
51
|
+
} else {
|
|
52
|
+
driver.swipeDown(selector, yoffset, speedinsec);
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error(error.message);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = { swipeleft, swipedown, swiperight, swipeup };
|