froth-webdriverio-framework 2.0.26 → 2.0.27
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 +31 -1
- package/commonMethods/random.js +64 -0
- package/package.json +2 -1
package/commonMethods/Utils.js
CHANGED
|
@@ -9,6 +9,14 @@ let scrollDownToView = null;
|
|
|
9
9
|
let scrollRightToView = null;
|
|
10
10
|
let assertText = null;
|
|
11
11
|
let connectToDB = null;
|
|
12
|
+
let randomtext = null;
|
|
13
|
+
let randomnumber = null;
|
|
14
|
+
let randomfloat = null;
|
|
15
|
+
let randomint = null;
|
|
16
|
+
let randomalphanum = null;
|
|
17
|
+
let randomdecimal = null;
|
|
18
|
+
let randomregex = null;
|
|
19
|
+
|
|
12
20
|
if (process.env.LOCATION == 'local') {
|
|
13
21
|
|
|
14
22
|
scrollToEnd = require("./scrollToEnd");
|
|
@@ -21,6 +29,13 @@ if (process.env.LOCATION == 'local') {
|
|
|
21
29
|
scrollRightToView = require('./scrollRightToView');
|
|
22
30
|
assertText = require('./assertText');
|
|
23
31
|
connectToDB = require('./connectToDB');
|
|
32
|
+
randomtext = require('./random').RANDOMTEXT;
|
|
33
|
+
randomnumber = require('./random').RNDNUMBER;
|
|
34
|
+
randomfloat = require('./random').RNDFLOAT;
|
|
35
|
+
randomint = require('./random').RNDINT;
|
|
36
|
+
randomalphanum = require('./random').RNDALPHANUM;
|
|
37
|
+
randomdecimal = require('./random').RNDDECIMAL;
|
|
38
|
+
randomregex = require('./random').RNDREGEX;
|
|
24
39
|
} else {
|
|
25
40
|
scrollToEnd = require('froth-webdriverio-framework/commonMethods/scrollToEnd');
|
|
26
41
|
clickIfVisible = require('froth-webdriverio-framework/commonMethods/clickIfVisible');
|
|
@@ -32,6 +47,14 @@ if (process.env.LOCATION == 'local') {
|
|
|
32
47
|
scrollRightToView = require('froth-webdriverio-framework/commonMethods/scrollRightToView');
|
|
33
48
|
assertText = require('froth-webdriverio-framework/commonMethods/assertText');
|
|
34
49
|
connectToDB = require('froth-webdriverio-framework/commonMethods/connectToDB');
|
|
50
|
+
randomtext = require('froth-webdriverio-framework/commonMethods/random').RANDOMTEXT;
|
|
51
|
+
randomnumber = require('froth-webdriverio-framework/commonMethods/random').RNDNUMBER;
|
|
52
|
+
randomfloat = require('froth-webdriverio-framework/commonMethods/random').RNDFLOAT;
|
|
53
|
+
randomint = require('froth-webdriverio-framework/commonMethods/random').RNDINT;
|
|
54
|
+
randomalphanum = require('froth-webdriverio-framework/commonMethods/random').RNDALPHANUM;
|
|
55
|
+
randomdecimal = require('froth-webdriverio-framework/commonMethods/random').RNDDECIMAL;
|
|
56
|
+
randomregex = require('froth-webdriverio-framework/commonMethods/random').RNDREGEX;
|
|
57
|
+
|
|
35
58
|
}
|
|
36
59
|
//export the variabels
|
|
37
60
|
module.exports = {
|
|
@@ -44,5 +67,12 @@ module.exports = {
|
|
|
44
67
|
scrollDownToView,
|
|
45
68
|
scrollRightToView,
|
|
46
69
|
assertText,
|
|
47
|
-
connectToDB
|
|
70
|
+
connectToDB,
|
|
71
|
+
randomtext,
|
|
72
|
+
randomnumber,
|
|
73
|
+
randomfloat,
|
|
74
|
+
randomint,
|
|
75
|
+
randomalphanum,
|
|
76
|
+
randomdecimal,
|
|
77
|
+
randomregex
|
|
48
78
|
};
|
|
@@ -0,0 +1,64 @@
|
|
|
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 RANDOMTEXT(length) {
|
|
16
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
17
|
+
let result = '';
|
|
18
|
+
for (let i = 0; i < length; i++) {
|
|
19
|
+
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function RNDALPHANUM(length) {
|
|
25
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
26
|
+
let result = '';
|
|
27
|
+
for (let i = 0; i < length; i++) {
|
|
28
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function RNDDECIMAL(min, max, decimalPlaces) {
|
|
34
|
+
let randomNum = Math.random() * (max - min) + min; // Generates a number between min and max
|
|
35
|
+
return parseFloat(randomNum.toFixed(decimalPlaces));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function RNDDECIMAL(decimalPlaces) {
|
|
39
|
+
let randomNum = Math.random(); // Generates a number between 0 and 1
|
|
40
|
+
return parseFloat(randomNum.toFixed(decimalPlaces));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function RNDREGEX(regex) {
|
|
44
|
+
return new RandExp(regex).gen();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
RNDNUMBER,
|
|
49
|
+
RNDFLOAT,
|
|
50
|
+
RNDINT,
|
|
51
|
+
RANDOMTEXT,
|
|
52
|
+
RNDALPHANUM,
|
|
53
|
+
RNDDECIMAL,
|
|
54
|
+
RNDREGEX
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// console.log(RNDNUMBER(1, 100));
|
|
58
|
+
// console.log(RNDFLOAT());
|
|
59
|
+
// console.log(RNDINT());
|
|
60
|
+
// console.log(RANDOMTEXT(10));
|
|
61
|
+
// console.log(RNDALPHANUM(10));
|
|
62
|
+
// console.log(RNDDECIMAL(100, 10000, 4));
|
|
63
|
+
// console.log(RNDDECIMAL(2));
|
|
64
|
+
// console.log(RNDREGEX(/[a-z]{4}\d{4}/));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "froth-webdriverio-framework",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.27",
|
|
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
|
}
|