froth-webdriverio-framework 2.0.26 → 2.0.29
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/commonMethods/Utils.js +46 -1
- package/commonMethods/assertText.js +7 -5
- package/commonMethods/random.js +72 -0
- package/commonMethods/storeToBuffer.js +45 -0
- package/config/api.conf.js +70 -0
- package/package.json +2 -1
package/commonMethods/Utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
// This file contains the common methods that are used in the test scripts
|
|
2
3
|
let scrollToEnd = null;
|
|
3
4
|
let clickIfVisible = null;
|
|
@@ -9,6 +10,17 @@ let scrollDownToView = null;
|
|
|
9
10
|
let scrollRightToView = null;
|
|
10
11
|
let assertText = null;
|
|
11
12
|
let connectToDB = null;
|
|
13
|
+
let randomtext = null;
|
|
14
|
+
let randomnumber = null;
|
|
15
|
+
let randomfloat = null;
|
|
16
|
+
let randomint = null;
|
|
17
|
+
let randomalphanum = null;
|
|
18
|
+
let randomdecimal = null;
|
|
19
|
+
let randomregex = null;
|
|
20
|
+
let storetext=null;
|
|
21
|
+
let storevalue=null;
|
|
22
|
+
let storeattributevalue=null;
|
|
23
|
+
|
|
12
24
|
if (process.env.LOCATION == 'local') {
|
|
13
25
|
|
|
14
26
|
scrollToEnd = require("./scrollToEnd");
|
|
@@ -21,6 +33,17 @@ if (process.env.LOCATION == 'local') {
|
|
|
21
33
|
scrollRightToView = require('./scrollRightToView');
|
|
22
34
|
assertText = require('./assertText');
|
|
23
35
|
connectToDB = require('./connectToDB');
|
|
36
|
+
randomtext = require('./random').RANDOMTEXT;
|
|
37
|
+
randomnumber = require('./random').RNDNUMBER;
|
|
38
|
+
randomfloat = require('./random').RNDFLOAT;
|
|
39
|
+
randomint = require('./random').RNDINT;
|
|
40
|
+
randomalphanum = require('./random').RNDALPHANUM;
|
|
41
|
+
randomdecimal = require('./random').RNDDECIMAL;
|
|
42
|
+
randomregex = require('./random').RNDREGEX;
|
|
43
|
+
storetext = require('./storeToBuffer').STORETEXT;
|
|
44
|
+
storevalue = require('./storeToBuffer').STOREVALUE;
|
|
45
|
+
storeattributevalue = require('./storeToBuffer').STOREATTRIBUTEVALUE;
|
|
46
|
+
|
|
24
47
|
} else {
|
|
25
48
|
scrollToEnd = require('froth-webdriverio-framework/commonMethods/scrollToEnd');
|
|
26
49
|
clickIfVisible = require('froth-webdriverio-framework/commonMethods/clickIfVisible');
|
|
@@ -32,6 +55,17 @@ if (process.env.LOCATION == 'local') {
|
|
|
32
55
|
scrollRightToView = require('froth-webdriverio-framework/commonMethods/scrollRightToView');
|
|
33
56
|
assertText = require('froth-webdriverio-framework/commonMethods/assertText');
|
|
34
57
|
connectToDB = require('froth-webdriverio-framework/commonMethods/connectToDB');
|
|
58
|
+
randomtext = require('froth-webdriverio-framework/commonMethods/random').RANDOMTEXT;
|
|
59
|
+
randomnumber = require('froth-webdriverio-framework/commonMethods/random').RNDNUMBER;
|
|
60
|
+
randomfloat = require('froth-webdriverio-framework/commonMethods/random').RNDFLOAT;
|
|
61
|
+
randomint = require('froth-webdriverio-framework/commonMethods/random').RNDINT;
|
|
62
|
+
randomalphanum = require('froth-webdriverio-framework/commonMethods/random').RNDALPHANUM;
|
|
63
|
+
randomdecimal = require('froth-webdriverio-framework/commonMethods/random').RNDDECIMAL;
|
|
64
|
+
randomregex = require('froth-webdriverio-framework/commonMethods/random').RNDREGEX;
|
|
65
|
+
storetext = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STORETEXT;
|
|
66
|
+
storevalue = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STOREVALUE;
|
|
67
|
+
storeattributevalue = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STOREATTRIBUTEVALUE;
|
|
68
|
+
|
|
35
69
|
}
|
|
36
70
|
//export the variabels
|
|
37
71
|
module.exports = {
|
|
@@ -44,5 +78,16 @@ module.exports = {
|
|
|
44
78
|
scrollDownToView,
|
|
45
79
|
scrollRightToView,
|
|
46
80
|
assertText,
|
|
47
|
-
connectToDB
|
|
81
|
+
connectToDB,
|
|
82
|
+
randomtext,
|
|
83
|
+
randomnumber,
|
|
84
|
+
randomfloat,
|
|
85
|
+
randomint,
|
|
86
|
+
randomalphanum,
|
|
87
|
+
randomdecimal,
|
|
88
|
+
randomregex,
|
|
89
|
+
storetext,
|
|
90
|
+
storevalue,
|
|
91
|
+
storeattributevalue
|
|
92
|
+
|
|
48
93
|
};
|
|
@@ -9,14 +9,16 @@ async function assertText(driver, elementSelector, expectedText) {
|
|
|
9
9
|
// Get the actual text from the element
|
|
10
10
|
// const element = await driver.$(elementSelector);
|
|
11
11
|
// console.log("actual text is:" + element)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
let element = await $(elementSelector)
|
|
13
|
+
const actualText = await element.getText();
|
|
14
|
+
console.log("actual text is:" + status)
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
let status = await expect(element).toHaveText(expectedText)
|
|
17
|
+
|
|
18
|
+
console.log("actual status text is:" + status)
|
|
17
19
|
|
|
18
20
|
// Compare the actual text with the expected text
|
|
19
|
-
if (
|
|
21
|
+
if (status) {
|
|
20
22
|
let annotationMessage = `Assertion pass. Actual text: ${actualText}, Expected text: ${expectedText}.`;
|
|
21
23
|
console.log(`Assertion pass. Actual text: ${actualText}, Expected text: ${expectedText}.`);
|
|
22
24
|
// await driver.execute(`browserstack_executor: {"action": "annotate", "arguments": {"data":"${annotationMessage}","level": "info"}}`);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const RandExp = require('randexp');
|
|
2
|
+
|
|
3
|
+
async function RNDNUMBER(min, max) {
|
|
4
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
async function RNDFLOAT() {
|
|
8
|
+
return Math.random();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async function RNDINT() {
|
|
12
|
+
return Math.floor(Math.random() * 100000); // You can choose any large multiplier for bigger ranges
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function RNDNUMBER(length) {
|
|
16
|
+
if (length <= 0) return null; // Handle invalid length
|
|
17
|
+
|
|
18
|
+
const min = Math.pow(10, length - 1); // Minimum value for the given length
|
|
19
|
+
const max = Math.pow(10, length) - 1; // Maximum value for the given length
|
|
20
|
+
|
|
21
|
+
return Math.floor(Math.random() * (max - min + 1)) + min; // Generate the random number
|
|
22
|
+
}
|
|
23
|
+
async function RANDOMTEXT(length) {
|
|
24
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
25
|
+
let result = '';
|
|
26
|
+
for (let i = 0; i < length; i++) {
|
|
27
|
+
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function RNDALPHANUM(length) {
|
|
33
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
34
|
+
let result = '';
|
|
35
|
+
for (let i = 0; i < length; i++) {
|
|
36
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function RNDDECIMAL(min, max, decimalPlaces) {
|
|
42
|
+
let randomNum = Math.random() * (max - min) + min; // Generates a number between min and max
|
|
43
|
+
return parseFloat(randomNum.toFixed(decimalPlaces));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function RNDDECIMAL(decimalPlaces) {
|
|
47
|
+
let randomNum = Math.random(); // Generates a number between 0 and 1
|
|
48
|
+
return parseFloat(randomNum.toFixed(decimalPlaces));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function RNDREGEX(regex) {
|
|
52
|
+
return new RandExp(regex).gen();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
RNDNUMBER,
|
|
57
|
+
RNDFLOAT,
|
|
58
|
+
RNDINT,
|
|
59
|
+
RANDOMTEXT,
|
|
60
|
+
RNDALPHANUM,
|
|
61
|
+
RNDDECIMAL,
|
|
62
|
+
RNDREGEX
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// console.log(RNDNUMBER(1, 100));
|
|
66
|
+
// console.log(RNDFLOAT());
|
|
67
|
+
// console.log(RNDINT());
|
|
68
|
+
// console.log(RANDOMTEXT(10));
|
|
69
|
+
// console.log(RNDALPHANUM(10));
|
|
70
|
+
// console.log(RNDDECIMAL(100, 10000, 4));
|
|
71
|
+
// console.log(RNDDECIMAL(2));
|
|
72
|
+
// console.log(RNDREGEX(/[a-z]{4}\d{4}/));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
async function STORETEXT(element, buffername) {
|
|
2
|
+
|
|
3
|
+
try {
|
|
4
|
+
let ele = await $(element);
|
|
5
|
+
// Get the actual text from the specified attribute
|
|
6
|
+
const actualText = await ele.getText();
|
|
7
|
+
console.log('Text stored in buffer:', actualText);
|
|
8
|
+
BUFFER.setItem(buffername, actualText);
|
|
9
|
+
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.log('Excption occured during storing the text into buffer', `${error.message}`);
|
|
12
|
+
console.error(error.message);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function STOREVALUE(element, buffername) {
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
let ele = await $(element);
|
|
20
|
+
// Get the actual text from the specified attribute
|
|
21
|
+
const actualText = await ele.getValue();
|
|
22
|
+
console.log('Value stored in buffer:', actualText);
|
|
23
|
+
BUFFER.setItem(buffername, actualText);
|
|
24
|
+
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.log('Excption occured during storing the value into buffer', `${error.message}`);
|
|
27
|
+
console.error(error.message);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function STOREATTRIBUTEVALUE(element, attribute, buffername) {
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
let ele = await $(element);
|
|
35
|
+
// Get the actual text from the specified attribute
|
|
36
|
+
const actualText = await ele.getAttribute(attribute);
|
|
37
|
+
console.log('Attr value stored in buffer:', actualText);
|
|
38
|
+
BUFFER.setItem(buffername, actualText);
|
|
39
|
+
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.log('Excption occured during storing the attribute value into buffer', `${error.message}`);
|
|
42
|
+
console.error(error.message);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
module.exports = { STORETEXT, STOREVALUE, STOREATTRIBUTEVALUE };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
const config = {
|
|
4
|
+
|
|
5
|
+
// ====================
|
|
6
|
+
// Capabilities
|
|
7
|
+
// ====================
|
|
8
|
+
capabilities: [{
|
|
9
|
+
maxInstances: 5,
|
|
10
|
+
browserName: 'chrome',
|
|
11
|
+
acceptInsecureCerts: true,
|
|
12
|
+
}],
|
|
13
|
+
|
|
14
|
+
// ====================
|
|
15
|
+
// Test Configurations
|
|
16
|
+
// ====================
|
|
17
|
+
logLevel: 'info', // Set the log level
|
|
18
|
+
bail: 0, // Set to 1 to stop the test suite after the first test failure
|
|
19
|
+
baseUrl: '', // Specify the base URL of your application
|
|
20
|
+
waitforTimeout: 60000, // Set the timeout for all waitFor* commands
|
|
21
|
+
connectionRetryTimeout: 90000, // Set the timeout in milliseconds for test retries
|
|
22
|
+
connectionRetryCount: 3, // Set the number of times to retry the entire spec file
|
|
23
|
+
|
|
24
|
+
// ====================
|
|
25
|
+
// Framework
|
|
26
|
+
// ====================
|
|
27
|
+
framework: 'mocha', // Use the Mocha framework
|
|
28
|
+
reporters: ['spec'], // Use the spec reporter
|
|
29
|
+
// reporterOptions: {
|
|
30
|
+
// allure: {
|
|
31
|
+
// outputDir: 'allure-results',
|
|
32
|
+
// disableWebdriverStepsReporting: true,
|
|
33
|
+
// disableWebdriverScreenshotsReporting: false,
|
|
34
|
+
// }
|
|
35
|
+
//},
|
|
36
|
+
// ====================
|
|
37
|
+
// Hooks
|
|
38
|
+
// ====================
|
|
39
|
+
before: function (capabilities, specs) {
|
|
40
|
+
// Code to run before the first test
|
|
41
|
+
const currentDate = new Date();
|
|
42
|
+
const timestamp = currentDate.toISOString().replace(/[:.]/g, '');
|
|
43
|
+
browser.saveScreenshot('./screenshot_' + timestamp + '.png');
|
|
44
|
+
|
|
45
|
+
},
|
|
46
|
+
after: function (capabilities, specs) {
|
|
47
|
+
// Code to run to take screenshots
|
|
48
|
+
const currentDate = new Date();
|
|
49
|
+
const timestamp = currentDate.toISOString().replace(/[:.]/g, '');
|
|
50
|
+
browser.saveScreenshot('./screenshot_' + timestamp + '.png');
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
// ====================
|
|
56
|
+
// BrowserStack Options
|
|
57
|
+
// ====================
|
|
58
|
+
browserstackOpts: {
|
|
59
|
+
// BrowserStack-specific options
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// ====================
|
|
63
|
+
// Mocha Options
|
|
64
|
+
// ====================
|
|
65
|
+
mochaOpts: {
|
|
66
|
+
ui: 'bdd', // Set the test interface to BDD
|
|
67
|
+
timeout: 60000, // Set the timeout for test cases in milliseconds
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
module.exports = config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "froth-webdriverio-framework",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.29",
|
|
4
4
|
"readme": "WebdriverIO Integration",
|
|
5
5
|
"description": "WebdriverIO and BrowserStack App Automate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"node-localstorage": "^3.0.5",
|
|
45
45
|
"pg": "^8.12.0",
|
|
46
46
|
"pg-promise": "^11.9.0",
|
|
47
|
+
"randexp": "^0.5.3",
|
|
47
48
|
"ts-node": "^10.9.2",
|
|
48
49
|
"typescript": "^5.4.5"
|
|
49
50
|
}
|