froth-webdriverio-framework 7.0.43 → 7.0.45

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.
@@ -1,34 +0,0 @@
1
- const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
2
-
3
- async function select4mDropDownValue(elementSelector, selectOption) {
4
- try {
5
- // let selectBox = await $(elementSelector);
6
- await $(elementSelector).selectByAttribute('value', selectOption);
7
-
8
- } catch (error) {
9
- console.error('Error occurred while selecting the option:', error);
10
- let annotationMessage = `Error occurred while selecting the option: ${error.message}.`;
11
- await amendToBrowserstack(annotationMessage, "error");
12
- }
13
- }
14
-
15
- async function select4mDropDownText(elementSelector, visibleText) {
16
- try {
17
- await $(elementSelector).selectByVisibleText(visibleText);
18
- } catch (error) {
19
- console.error('Error occurred while selecting the option by text:', error);
20
- let annotationMessage = `Error occurred while selecting the option by text: ${error.message}.`;
21
- await amendToBrowserstack(annotationMessage, "error");
22
- }
23
- }
24
-
25
- // async function amendToBrowserstack(annotationMessage, level) {
26
- // try {
27
- // await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
28
-
29
- // } catch (error) {
30
- // console.error('Error occurred while verifying text:', error);
31
- // // throw error;
32
- // }
33
- // }
34
- module.exports = { select4mDropDownValue,select4mDropDownText };
@@ -1,161 +0,0 @@
1
- // // process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
2
-
3
- // const Imap = require('imap');
4
- // const { simpleParser } = require('mailparser');
5
- // const cheerio = require('cheerio');
6
-
7
- // /**
8
- // * Connects to an IMAP inbox, parses emails, and extracts all unique links.
9
- // * @param {Object} config - IMAP config { user, password, host, port, tls }
10
- // * @param {Object} [filter] - Optional filter { subject, from }
11
- // * @returns {Promise<Array<{link: string, text: string}>>}
12
- // */
13
- // async function getEmailLinks(username,app_password, subjectdetails,fromemail) {
14
- // const config = {
15
- // user: username,
16
- // password: app_password,
17
- // host: 'imap.gmail.com',
18
- // port: 993,
19
- // tls: true
20
- // };
21
- // const filter = {
22
- // subject: subjectdetails,
23
- // from: fromemail
24
- // };
25
- // const imap = new Imap(config);
26
-
27
- // function openInbox(cb) {
28
- // imap.openBox('INBOX', true, cb);
29
- // }
30
-
31
- // return new Promise((resolve, reject) => {
32
- // let results = new Map();
33
- // let allLinks = [];
34
- // let parseDone;
35
- // const parsePromise = new Promise(res => { parseDone = res; });
36
-
37
- // imap.once('ready', function () {
38
- // openInbox(function (err, box) {
39
- // if (err) return cleanup(err);
40
-
41
- // // Build search criteria
42
- // let searchCriteria = ['ALL'];
43
- // if (filter.subject) searchCriteria.push(['HEADER', 'SUBJECT', filter.subject]);
44
- // if (filter.from) searchCriteria.push(['FROM', filter.from]);
45
-
46
- // imap.search(searchCriteria, function (err, uids) {
47
- // if (err) return cleanup(err);
48
- // if (!uids.length) return cleanup(null, []);
49
-
50
- // // Sort UIDs descending to get the latest email first
51
- // uids = uids.sort((a, b) => b - a);
52
- // // Only fetch the latest email
53
- // const latestUid = uids[0];
54
- // const fetch = imap.fetch([latestUid], { bodies: '' });
55
- // fetch.on('message', function (msg) {
56
- // let buffer = '';
57
- // msg.on('body', function (stream) {
58
- // stream.on('data', function (chunk) {
59
- // buffer += chunk.toString('utf8');
60
- // });
61
- // });
62
- // msg.once('end', async function () {
63
- // try {
64
- // const parsed = await simpleParser(buffer);
65
- // let links = [];
66
-
67
- // // Extract from HTML with element context
68
- // if (parsed.html) {
69
- // const $ = cheerio.load(parsed.html);
70
- // $('a[href], button[href], [role="button"][href], img[src], area[href]').each((_, el) => {
71
- // let link = null;
72
- // let text = '';
73
- // let elementType = el.tagName;
74
- // if (elementType === 'a' || elementType === 'area') {
75
- // link = $(el).attr('href');
76
- // text = $(el).text().trim() || link;
77
- // } else if (elementType === 'img') {
78
- // link = $(el).attr('src');
79
- // text = $(el).attr('alt') || link;
80
- // } else if (elementType === 'button' || $(el).attr('role') === 'button') {
81
- // link = $(el).attr('href');
82
- // text = $(el).text().trim() || link;
83
- // }
84
- // if (link) {
85
- // links.push({ link, text, element: elementType });
86
- // }
87
- // });
88
- // }
89
-
90
- // // Extract from plaintext
91
- // if (parsed.text) {
92
- // const urlRegex = /(https?:\/\/[^\s]+)/g;
93
- // let match;
94
- // while ((match = urlRegex.exec(parsed.text))) {
95
- // links.push({ link: match[1], text: match[1], element: 'text' });
96
- // }
97
- // }
98
-
99
- // // Deduplicate by link and element context
100
- // for (const l of links) {
101
- // const key = l.link + '|' + l.element + '|' + l.text;
102
- // if (!results.has(key)) {
103
- // results.set(key, { link: l.link, text: l.text, element: l.element });
104
- // }
105
- // }
106
- // allLinks = Array.from(results.values());
107
- // parseDone();
108
- // } catch (e) {
109
- // // Log and continue
110
- // console.error('Parse error:', e);
111
- // parseDone();
112
- // }
113
- // });
114
- // });
115
- // fetch.once('error', cleanup);
116
- // fetch.once('end', async () => {
117
- // await parsePromise;
118
- // cleanup(null, allLinks);
119
- // });
120
- // });
121
- // });
122
- // });
123
-
124
- // imap.once('error', cleanup);
125
-
126
- // function cleanup(err, data) {
127
- // imap.end();
128
- // if (err) reject(err);
129
- // else resolve(data);
130
- // }
131
-
132
- // imap.connect();
133
- // });
134
- // }
135
-
136
- // async function findLinks(links,searchText) {
137
- // const findLinkByText = (links, searchText) => {
138
- // return links.find(l => l.text && l.text.toLowerCase().includes(searchText.toLowerCase()));
139
- // };
140
- // // Example usage:
141
- // const found = findLinkByText(links, searchText);
142
- // return found ? found.link : null;
143
- // }
144
-
145
-
146
- // // Example main function for direct execution
147
- // // if (require.main === module) {
148
- // // (async () => {
149
-
150
- // // const links = await extractEmailLinks('gfntesting44@gmail.com','wtrd qfee dicr hpba', "GFN Testing, review your Google Account settings","no-reply@google.com");
151
- // // console.log('Extracted links in main:', links);
152
- // // const foundLink = await findLinks(links,"Privacy Policy");
153
- // // console.log('Found Link: ', foundLink);
154
-
155
-
156
- // // })();
157
-
158
- // // }
159
-
160
- // module.exports = { getEmailLinks ,findLinks}
161
-
@@ -1,64 +0,0 @@
1
- // JWT generation script adapted from
2
- // https://gist.github.com/corbanb/db03150abbe899285d6a86cc480f674d
3
- const CryptoJS = require('crypto-js');
4
-
5
- var jwtSecret = "PJJP3CB51A29E8B9A70B29AB5FA3FC5FAFEFB34CFD881D629F3C892E9DF9F169AFA3PJPJ"
6
-
7
- // Set headers for JWT
8
- var header = {
9
- 'typ': 'JWT',
10
- 'alg': 'HS256'
11
- };
12
-
13
- // Prepare timestamp in seconds
14
- var currentTimestamp = Math.floor(Date.now() / 1000)
15
-
16
-
17
- function base64urlEncode(source) {
18
- let encoded = CryptoJS.enc.Base64.stringify(source);
19
- encoded = encoded.replace(/=+$/, ''); // Remove padding
20
- encoded = encoded.replace(/\+/g, '-'); // Replace "+" with "-"
21
- encoded = encoded.replace(/\//g, '_'); // Replace "/" with "_"
22
- return encoded;
23
- }
24
-
25
- function generateJWTToken(payload) {
26
- // Encode the header
27
- const stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header));
28
- const encodedHeader = base64urlEncode(stringifiedHeader);
29
-
30
- // Encode the payload
31
- const stringifiedPayload = CryptoJS.enc.Utf8.parse(JSON.stringify(payload));
32
- const encodedPayload = base64urlEncode(stringifiedPayload);
33
-
34
- // Combine the header and payload
35
- const token = `${encodedHeader}.${encodedPayload}`;
36
-
37
- // Sign the token
38
- const signature = CryptoJS.HmacSHA256(token, jwtSecret);
39
- const encodedSignature = base64urlEncode(signature);
40
-
41
- // Return the full token
42
- return `${token}.${encodedSignature}`;
43
- }
44
-
45
- //const jwt = generateJWT();
46
- //pm.environment.set('jwt_signed', signedToken)
47
- //console.log('Signed and encoded JWT', jwt)
48
-
49
-
50
- // function main() {
51
- // // JWT Payload
52
- // const payload = {
53
- // iss: "YTLC_TEST_AUTOMATION_APP",
54
- // iat: currentTimestamp, // Issued at
55
- // exp: currentTimestamp + 200, // Expiry time: 30 seconds from issuance
56
- // user_agent: {
57
- // id: "janga.reddy@ytl.com"
58
- // }
59
- // };
60
-
61
- // console.log('JWT signed token:', generateJWTToken(payload));
62
- // }
63
- //main()
64
- module.exports = { generateJWTToken}
@@ -1,73 +0,0 @@
1
- const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
2
-
3
- async function logJsonData2Table(jsonData) {
4
- try {
5
- console.log("Logging JSON data to table format in BrowserStack:");
6
- console.log(JSON.stringify(jsonData, null, 2));
7
-
8
- if (!Array.isArray(jsonData) || jsonData.length === 0) {
9
- await amendToBrowserstack("No data to log", "info");
10
- return;
11
- }
12
-
13
- // --- Extract keys dynamically (columns) ---
14
- const keys = Object.keys(jsonData[0]);
15
-
16
- // --- Calculate max width for each column ---
17
- const colWidths = {};
18
- keys.forEach(key => {
19
- colWidths[key] = Math.max(
20
- key.length,
21
- ...jsonData.map(row => String(row[key] ?? "").length)
22
- ) + 2;
23
- });
24
-
25
- // --- Build line separator ---
26
- const line = "-".repeat(
27
- keys.reduce((sum, key) => sum + colWidths[key], 0) + keys.length + 1
28
- );
29
-
30
- // --- Build header ---
31
- let table = line + "\n";
32
- table += "|" + keys.map(key => ` ${key.padEnd(colWidths[key])}`).join("|") + "|\n";
33
- table += line + "\n";
34
-
35
- // --- Build rows ---
36
- jsonData.forEach(row => {
37
- table += "|" + keys.map(key => ` ${String(row[key] ?? "").padEnd(colWidths[key])}`).join("|") + "|\n";
38
- });
39
-
40
- table += line;
41
- console.log(table);
42
- // --- Send to BrowserStack ---
43
- await amendToBrowserstack(table, "info");
44
-
45
- } catch (error) {
46
- console.error('Error occurred while logging JSON data to table:', error);
47
- // let annotationMessage = `Error occurred while logging JSON data to table: ${error.message}.`;
48
- // await amendToBrowserstack(annotationMessage, "error");
49
- }
50
- }
51
- module.exports = {
52
- logJsonData2Table
53
- };
54
-
55
- // // Main function to execute the API call
56
- // async function main() {
57
- // try {
58
- // /// BUFFER.setItem("EXECUTION_SESSIONID","297666e2fd4195de98d7da3b359669072ff41a2a");
59
- // const pageTimes = "[{ name: 'Homepage', time: 120 },{ name: 'Service Account Page', time: 250 },{ name: 'Search Results', time: 180 }]";
60
-
61
- // await logJsonData2Table(pageTimes, "info");
62
- // // const data = [
63
- // // { id: 1, score: 95.5, passed: true },
64
- // // { id: 2, score: 67.2, passed: false },
65
- // // { id: 3, score: null, passed: "N/A" }
66
- // // ];
67
- // // await logJsonData2Table(data, "info");
68
- // } catch (error) {
69
- // console.error('Error in main function:', error);
70
- // }
71
- // }
72
-
73
- // main();
@@ -1,230 +0,0 @@
1
- const RandExp = require('randexp');
2
-
3
- // Random number generator that can handle both range and length
4
- async function RNDNUMBER(minOrLength, max) {
5
- if (max !== undefined) {
6
- // If max is provided, generate a number within the specified range
7
- return Math.floor(Math.random() * (max - minOrLength + 1)) + minOrLength;
8
- } else {
9
- // Otherwise, generate a random number of the specified length
10
- const length = minOrLength || 18; // Default to 18 digits if no length is provided
11
- // if (length <= 0) length = 18; // Default to 18 digits if length is invalid
12
-
13
- const min = Math.pow(10, length - 1); // Minimum value for the given length
14
- const max = Math.pow(10, length) - 1; // Maximum value for the given length
15
-
16
- return Math.floor(Math.random() * (max - min + 1)) + min;
17
- }
18
- }
19
-
20
- // Random floating-point number between 0 and 1
21
- async function RNDFLOAT() {
22
- return Math.random();
23
- }
24
-
25
- // Random integer between 0 and 100000 (large multiplier range)
26
- async function RNDINT() {
27
- return Math.floor(Math.random() * 100000);
28
- }
29
-
30
- // Random text string of specified length
31
- async function RANDOMTEXT(length) {
32
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
33
- let result = '';
34
- for (let i = 0; i < length; i++) {
35
- result += characters.charAt(Math.floor(Math.random() * characters.length));
36
- }
37
- return result;
38
- }
39
-
40
- // Random alphanumeric string of specified length
41
- async function RNDALPHANUM(length) {
42
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
43
- let result = '';
44
- for (let i = 0; i < length; i++) {
45
- result += chars.charAt(Math.floor(Math.random() * chars.length));
46
- }
47
- return result;
48
- }
49
-
50
- async function RNDDECIMAL(minOrLength, max, decimalPlaces) {
51
- if (max !== undefined) {
52
- // If max is provided, generate a decimal number within the specified range
53
- let randomNum = Math.random() * (max - minOrLength) + minOrLength;
54
- console.log(randomNum);
55
- return parseFloat(randomNum.toFixed(decimalPlaces));
56
- } else {
57
- // Otherwise, generate a random decimal number between 0 and 1, rounded to the specified decimal places
58
- let length = minOrLength;
59
- const integerLength = length - decimalPlaces - 1; // Subtract 1 for the decimal point
60
- let integerPart = 0;
61
-
62
- if (integerLength > 0) {
63
- const minInt = Math.pow(10, integerLength - 1);
64
- const maxInt = Math.pow(10, integerLength) - 1;
65
-
66
- // Generate the integer part
67
- integerPart = Math.floor(Math.random() * (maxInt - minInt + 1)) + minInt;
68
- }
69
- // Generate the decimal part
70
- const decimalFactor = Math.pow(10, decimalPlaces);
71
- const decimalPart = Math.floor(Math.random() * decimalFactor);
72
- // Combine integer and decimal parts
73
- const result = `${integerPart}.${decimalPart.toString().padStart(decimalPlaces, '0')}`;
74
- return result;
75
- }
76
- }
77
-
78
-
79
- // Random string based on regex pattern
80
- async function RNDREGEX(regex) {
81
- console.log("inside random regex", regex);
82
- return new RandExp(regex).gen();
83
- }
84
-
85
- async function RNDDATE(startYear = 1950, endYear = 2005, format = 'YYMMDD') {
86
- // Generate a random year between startYear and endYear
87
- const start = new Date(`${startYear}-01-01`).getTime();
88
- const end = new Date(`${endYear}-12-31`).getTime();
89
-
90
- const randomTimestamp = start + Math.random() * (end - start);
91
- const randomDate = new Date(randomTimestamp);
92
- console.log(randomDate);
93
- return FORMATDATE(randomDate, format);
94
- }
95
-
96
- async function FORMATDATE(date, format) {
97
- const yy = String(date.getFullYear()).slice(2);
98
- const yyyy = String(date.getFullYear());
99
- const mm = String(date.getMonth() + 1).padStart(2, '0');
100
- const dd = String(date.getDate()).padStart(2, '0');
101
-
102
- switch (format.toUpperCase()) {
103
- case 'YYMMDD': return `${yy}${mm}${dd}`;
104
- case 'DDMMYY': return `${dd}${mm}${yy}`;
105
- case 'YYYYMMDD': return `${yyyy}${mm}${dd}`;
106
- case 'DDMMYYYY': return `${dd}${mm}${yyyy}`;
107
- case 'MMDDYY': return `${mm}${dd}${yy}`;
108
- case 'MMDDYYYY': return `${mm}${dd}${yyyy}`;
109
- case 'YYDDMM': return `${yy}${dd}${mm}`;
110
- case 'YYYYDDMM': return `${yyyy}${dd}${mm}`;
111
- default: return `${yy}${mm}${dd}`; // Fallback to YYMMDD
112
- }
113
- }
114
- // Main function to process templates and replace placeholders with random values
115
- async function RANDOM(template, datatype) {
116
- const regex = /\{(.*?)\}/g;
117
- let matches = [...template.matchAll(regex)];
118
-
119
- // Iterate over all matches and replace them with the resolved values
120
- let replacements = await Promise.all(matches.map(async (match) => {
121
- const content = match[1]; // Get the content inside { ... }
122
-
123
- const parts = content.split(/[\[\]]/).filter(Boolean); // Split by square brackets
124
- const type = parts[0];
125
- console.log("type is :" + type);
126
- console.log("parts are :" + parts);
127
- switch (type) {
128
- case 'RND':
129
- if (parts.length === 1) {
130
- return await RNDNUMBER(); // {RND} - Default to 5-digit number
131
- }
132
- else if (parts.length === 2) {
133
- return await RNDNUMBER(parseInt(parts[1])); // {RND[length]}
134
- } else if (parts.length === 3) {
135
- return await RNDNUMBER(parseInt(parts[1]), parseInt(parts[2])); // {RND[min][max]}
136
- } else {
137
- return await RNDNUMBER(); // {RND} - Default to 5-digit number
138
- }
139
- break;
140
-
141
- case 'RNDDECIMAL':
142
- console.log(parts);
143
- if (parts.length === 3) {
144
- return await RNDDECIMAL(parseInt(parts[1]), undefined, parseInt(parts[2])); // {RNDDECIMAL[length][decimalPlaces]}
145
- } else if (parts.length === 4) {
146
- return await RNDDECIMAL(parseInt(parts[1]), parseInt(parts[2]), parseInt(parts[3])); // {RNDDECIMAL[length][decimalPlaces]}
147
- } else {
148
- return await RNDDECIMAL(6, undefined, 2); // {RNDDECIMAL[length][decimalPlaces]}
149
- }
150
- break;
151
-
152
- case 'RANDOMTEXT':
153
- return await RANDOMTEXT(parseInt(parts[1])); // {RANDOMTEXT[length]}
154
- break;
155
- case 'CTMSTMP':
156
- console.log("inside CTMSTMP",Date.now());
157
- return Date.now(); // Current timestamp
158
- break;
159
-
160
- case 'RANDOMREGEX':
161
- let regexPattern;
162
- if (parts.length === 3) {
163
- regexPattern = `[${parts[1]}]{${parts[2]}}`; // {RANDOMREGEX[pattern][length]}
164
- console.log("regex pattern is :" + regexPattern);
165
- } else if (parts.length === 2) {
166
- regexPattern = `[${parts[1]}]{10}`; // {RANDOMREGEX[pattern][length]}
167
- console.log("regex pattern is :" + regexPattern);
168
- }
169
- let regex = new RegExp(regexPattern);
170
- return await RNDREGEX(regex); // Generate random string based on regex
171
- break;
172
-
173
- case 'RNDDATE':
174
- return await RNDDATE(parseInt(parts[1]), parseInt(parts[2])); // Generate random date of birth
175
- break;
176
-
177
- default:
178
- return match[0]; // If no match found, return original template string
179
- break;
180
-
181
- }
182
- }));
183
-
184
- // Replace all matches with their resolved values
185
- let result = template;
186
- matches.forEach((match, index) => {
187
- result = result.replace(match[0], replacements[index]);
188
- });
189
- datatype = datatype.toLowerCase();
190
-
191
- if (datatype == 'integer') {
192
- result = parseInt(result);
193
- }
194
- else if (datatype == 'decimal') {
195
- console.log("insude decimal");
196
- result = parseFloat(result);
197
- }
198
- else if (datatype == 'string') {
199
- result = result.toString();
200
- }
201
-
202
- return result;
203
- }
204
-
205
- // Example function to test the template replacement
206
- // async function main() {
207
-
208
- // let template = "SUBHRASUBUDHI {CTMSTMP} @GMAQIL.COM";
209
- // let result = await RANDOM(template, 'STRING');
210
- // console.log(result);
211
- // console.log(typeof result);
212
- // // template = "{RANDOMREGEX[\\\\d{5}(-\\\\\d{4})?][10]}";
213
- // // result = await RANDOM(template, 'STRING');
214
- // // console.log(result);
215
- // // console.log(typeof result);
216
-
217
- // }
218
-
219
- //main();
220
- module.exports = {
221
- RNDNUMBER,
222
- RNDFLOAT,
223
- RNDINT,
224
- RANDOMTEXT,
225
- RNDALPHANUM,
226
- RNDDECIMAL,
227
- RNDREGEX,
228
- RANDOM,
229
- RNDDATE
230
- };
@@ -1,104 +0,0 @@
1
- async function scrollToEnd(maxSwipes, steps) {
2
-
3
- try {
4
- console.log('Scrolling to end');
5
- await $('android=new UiScrollable(new UiSelector().scrollable(true)).scrollToEnd(' + maxSwipes + ',' + steps + ')');
6
- await driver.pause(3000);
7
- console.log('Scrolled to end');
8
- } catch (error) {
9
- console.error(error.message);
10
- }
11
- }
12
-
13
- async function scrollToLeft(steps) {
14
-
15
- try {
16
- console.log('Scrolling to left');
17
- await $('android=new UiScrollable(new UiSelector().scrollable(true)).scrollable.setAsHorizontalList().scrollBackward(' + steps + ')');
18
- await driver.pause(3000);
19
- console.log('Scrolled to left');
20
- } catch (error) {
21
- console.error(error.message);
22
- }
23
- }
24
-
25
- async function scrollToBeginning(maxSwipes, steps) {
26
-
27
- try {
28
- console.log('Scrolling to beginning');
29
- await $('android=new UiScrollable(new UiSelector().scrollable(true)).scrollToBeginning(' + maxSwipes + ',' + steps + ')');
30
- await driver.pause(3000);
31
- console.log('Scrolled to beginning');
32
- } catch (error) {
33
- console.error(error.message);
34
- }
35
- }
36
- async function scrollRightToView(text) {
37
-
38
- try {
39
- console.log('Scrolling to right until text is found');
40
- await $('android=new UiScrollable(new UiSelector().scrollable(true)).setAsHorizontalList().scrollTextIntoView("' + text + '")');
41
- await driver.pause(3000);
42
- console.log('Scrolled to right completed');
43
- } catch (error) {
44
- console.error(error.message);
45
- }
46
- }
47
- async function scrollDownToView(text) {
48
-
49
- try {
50
- console.log('Scrolling down until text is found');
51
- await $('android=new UiScrollable(new UiSelector().scrollable(true)).scrollTextIntoView("' + text + '")');
52
- await driver.pause(3000);
53
- console.log('Scrolled down completed');
54
- } catch (error) {
55
- console.error(error.message);
56
- }
57
- }
58
- async function scrollToRight(steps) {
59
-
60
- try {
61
- console.log('Scrolling to right');
62
- await $('android=new UiScrollable(new UiSelector().scrollable(true)).scrollable.setAsHorizontalList().scrollForward(' + steps + ')');
63
- await driver.pause(3000);
64
- console.log('Scrolled to right');
65
- } catch (error) {
66
- console.error(error.message);
67
- }
68
- }
69
-
70
- async function scrollIntoView(element){
71
- try{
72
- const elem = await $(element);
73
- // scroll to specific element
74
- await elem.scrollIntoView();
75
- // center element within the viewport
76
- // await elem.scrollIntoView({ block: 'center', inline: 'center' });
77
-
78
- }catch(error){
79
- console.error(error.message);
80
- }
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};