froth-webdriverio-framework 2.0.31 → 2.0.33
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 +69 -54
- package/commonMethods/assert.js +73 -0
- package/commonMethods/clickIfVisible.js +2 -2
- package/commonMethods/scroll.js +82 -0
- package/commonMethods/swipe.js +29 -0
- package/package.json +1 -1
- package/commonMethods/assertText.js +0 -42
- package/commonMethods/connectToDB.js +0 -87
- package/commonMethods/scrollDownToView.js +0 -12
- package/commonMethods/scrollRightToView.js +0 -12
- package/commonMethods/scrollToBeginning.js +0 -12
- package/commonMethods/scrollToEnd.js +0 -13
- package/commonMethods/scrollToLeft.js +0 -12
- package/commonMethods/scrollToRight.js +0 -12
package/commonMethods/Utils.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
const assert = require("assert");
|
|
1
2
|
|
|
2
3
|
// This file contains the common methods that are used in the test scripts
|
|
3
4
|
let scrollToEnd = null;
|
|
4
|
-
let clickIfVisible = null;
|
|
5
|
-
let verifyTextInFieldAttribute = null;
|
|
6
5
|
let scrollToBeginning = null;
|
|
7
6
|
let scrollToLeft = null;
|
|
8
7
|
let scrollToRight = null;
|
|
9
8
|
let scrollDownToView = null;
|
|
10
9
|
let scrollRightToView = null;
|
|
10
|
+
|
|
11
|
+
let clickIfVisible = null;
|
|
12
|
+
|
|
11
13
|
let assertText = null;
|
|
12
|
-
let connectToDB = null;
|
|
13
14
|
let randomtext = null;
|
|
14
15
|
let randomnumber = null;
|
|
15
16
|
let randomfloat = null;
|
|
@@ -17,68 +18,81 @@ let randomint = null;
|
|
|
17
18
|
let randomalphanum = null;
|
|
18
19
|
let randomdecimal = null;
|
|
19
20
|
let randomregex = null;
|
|
20
|
-
let storetext=null;
|
|
21
|
-
let storevalue=null;
|
|
22
|
-
let storeattributevalue=null;
|
|
23
|
-
|
|
21
|
+
let storetext = null;
|
|
22
|
+
let storevalue = null;
|
|
23
|
+
let storeattributevalue = null;
|
|
24
|
+
let assertAttributeValue = null;
|
|
25
|
+
let basepath = null;
|
|
26
|
+
let scrollIntoView = null;
|
|
24
27
|
if (process.env.LOCATION == 'local') {
|
|
28
|
+
basepath = ".";
|
|
29
|
+
} else {
|
|
30
|
+
basepath = "froth-webdriverio-framework/commonMethods";
|
|
31
|
+
}
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
scrollRightToView = require('./scrollRightToView');
|
|
34
|
-
assertText = require('./assertText');
|
|
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;
|
|
33
|
+
scrollToEnd = require(basepath + "/scroll").scrollToEnd;
|
|
34
|
+
scrollToBeginning = require(basepath + '/scroll').scrollToBeginning;
|
|
35
|
+
scrollToLeft = require(basepath + '/scroll').scrollToLeft;
|
|
36
|
+
scrollToRight = require(basepath + '/scroll').scrollToRight;
|
|
37
|
+
scrollDownToView = require(basepath + '/scroll').scrollDownToView;
|
|
38
|
+
scrollRightToView = require(basepath + '/scroll').scrollRightToView;
|
|
39
|
+
scrollIntoView = require(basepath + '/scroll').scrollIntoView;
|
|
46
40
|
|
|
47
|
-
|
|
48
|
-
scrollToEnd = require('froth-webdriverio-framework/commonMethods/scrollToEnd');
|
|
49
|
-
clickIfVisible = require('froth-webdriverio-framework/commonMethods/clickIfVisible');
|
|
50
|
-
verifyTextInFieldAttribute = require('froth-webdriverio-framework/commonMethods/verifyTextInFieldAttribute');
|
|
51
|
-
scrollToBeginning = require('froth-webdriverio-framework/commonMethods/scrollToBeginning');
|
|
52
|
-
scrollToLeft = require('froth-webdriverio-framework/commonMethods/scrollToLeft');
|
|
53
|
-
scrollToRight = require('froth-webdriverio-framework/commonMethods/scrollToRight');
|
|
54
|
-
scrollDownToView = require('froth-webdriverio-framework/commonMethods/scrollDownToView');
|
|
55
|
-
scrollRightToView = require('froth-webdriverio-framework/commonMethods/scrollRightToView');
|
|
56
|
-
assertText = require('froth-webdriverio-framework/commonMethods/assertText');
|
|
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;
|
|
41
|
+
clickIfVisible = require(basepath + "/clickIfVisible");
|
|
68
42
|
|
|
69
|
-
|
|
43
|
+
assertText = require(basepath + '/assert').assertText;
|
|
44
|
+
assertAttributeValue = require(basepath + '/assert').assertAttributeValue;
|
|
45
|
+
|
|
46
|
+
randomtext = require(basepath + '/random').RANDOMTEXT;
|
|
47
|
+
randomnumber = require(basepath + '/random').RNDNUMBER;
|
|
48
|
+
randomfloat = require(basepath + '/random').RNDFLOAT;
|
|
49
|
+
randomint = require(basepath + '/random').RNDINT;
|
|
50
|
+
randomalphanum = require(basepath + '/random').RNDALPHANUM;
|
|
51
|
+
randomdecimal = require(basepath + '/random').RNDDECIMAL;
|
|
52
|
+
randomregex = require(basepath + '/random').RNDREGEX;
|
|
53
|
+
|
|
54
|
+
storetext = require(basepath + '/storeToBuffer').STORETEXT;
|
|
55
|
+
storevalue = require(basepath + '/storeToBuffer').STOREVALUE;
|
|
56
|
+
storeattributevalue = require(basepath + '/storeToBuffer').STOREATTRIBUTEVALUE;
|
|
57
|
+
|
|
58
|
+
// } else {
|
|
59
|
+
// scrollToEnd = require('froth-webdriverio-framework/commonMethods/scroll').scrollToEnd;
|
|
60
|
+
// scrollDownToView = require('froth-webdriverio-framework/commonMethods/scroll').scrollDownToView;
|
|
61
|
+
// scrollToBeginning = require('froth-webdriverio-framework/commonMethods/scroll').scrollToBeginning;
|
|
62
|
+
// scrollToLeft = require('froth-webdriverio-framework/commonMethods/scroll').scrollToLeft;
|
|
63
|
+
// scrollToRight = require('froth-webdriverio-framework/commonMethods/scroll').scrollToRight;
|
|
64
|
+
// scrollRightToView = require('froth-webdriverio-framework/commonMethods/scroll').scrollRightToView;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
// clickIfVisible = require('froth-webdriverio-framework/commonMethods/clickIfVisible');
|
|
68
|
+
|
|
69
|
+
// assertText = require('froth-webdriverio-framework/commonMethods/assert').assertText;
|
|
70
|
+
// assertAttributeValue = require('froth-webdriverio-framework/commonMethods/assert').assertAttributeValue;
|
|
71
|
+
|
|
72
|
+
// randomtext = require('froth-webdriverio-framework/commonMethods/random').RANDOMTEXT;
|
|
73
|
+
// randomnumber = require('froth-webdriverio-framework/commonMethods/random').RNDNUMBER;
|
|
74
|
+
// randomfloat = require('froth-webdriverio-framework/commonMethods/random').RNDFLOAT;
|
|
75
|
+
// randomint = require('froth-webdriverio-framework/commonMethods/random').RNDINT;
|
|
76
|
+
// randomalphanum = require('froth-webdriverio-framework/commonMethods/random').RNDALPHANUM;
|
|
77
|
+
// randomdecimal = require('froth-webdriverio-framework/commonMethods/random').RNDDECIMAL;
|
|
78
|
+
// randomregex = require('froth-webdriverio-framework/commonMethods/random').RNDREGEX;
|
|
79
|
+
|
|
80
|
+
// storetext = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STORETEXT;
|
|
81
|
+
// storevalue = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STOREVALUE;
|
|
82
|
+
// storeattributevalue = require('froth-webdriverio-framework/commonMethods/storeToBuffer').STOREATTRIBUTEVALUE;
|
|
83
|
+
|
|
84
|
+
// }
|
|
70
85
|
//export the variabels
|
|
71
86
|
module.exports = {
|
|
72
87
|
scrollToEnd,
|
|
73
|
-
clickIfVisible,
|
|
74
|
-
verifyTextInFieldAttribute,
|
|
75
88
|
scrollToBeginning,
|
|
76
89
|
scrollToLeft,
|
|
77
90
|
scrollToRight,
|
|
78
91
|
scrollDownToView,
|
|
79
92
|
scrollRightToView,
|
|
80
|
-
|
|
81
|
-
|
|
93
|
+
clickIfVisible,
|
|
94
|
+
assertText,
|
|
95
|
+
assertAttributeValue,
|
|
82
96
|
randomtext,
|
|
83
97
|
randomnumber,
|
|
84
98
|
randomfloat,
|
|
@@ -88,6 +102,7 @@ module.exports = {
|
|
|
88
102
|
randomregex,
|
|
89
103
|
storetext,
|
|
90
104
|
storevalue,
|
|
91
|
-
storeattributevalue
|
|
105
|
+
storeattributevalue,
|
|
106
|
+
scrollIntoView
|
|
92
107
|
|
|
93
108
|
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Function to verify text in Android app
|
|
2
|
+
|
|
3
|
+
async function assertText(elementSelector, expectedText) {
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
console.log("inside the assert text function" + elementSelector)
|
|
7
|
+
try {
|
|
8
|
+
let element = await $(elementSelector)
|
|
9
|
+
let assertionStatus = false; // Initialize status
|
|
10
|
+
try {
|
|
11
|
+
await expect(element).toHaveText(expectedText);
|
|
12
|
+
assertionStatus = true; // If assertion passes, set status to true
|
|
13
|
+
console.log("Assertion succeeded.");
|
|
14
|
+
actualText = await element.getText();
|
|
15
|
+
let annotationMessage = `Assertion passed. Actual text: ${actualText}, Expected text: ${expectedText}.`;
|
|
16
|
+
await amendToBrowserstack(annotationMessage, "info");
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.log(`Assertion failed. Expected text: ,${expectedText}.`);
|
|
19
|
+
let annotationMessage = `Assertion failed. Expected text: ,${expectedText}.`;
|
|
20
|
+
await amendToBrowserstack(annotationMessage, "error");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error('Error occurred while verifying text:', error);
|
|
26
|
+
let annotationMessage = `Error occurred while verifying text: ${error.message}.`;
|
|
27
|
+
await amendToBrowserstack(annotationMessage, "error");
|
|
28
|
+
// throw error;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function assertAttributeValue(elementSelector, attributeName, expectedText) {
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
console.log("inside the assertAttributeValue function" + elementSelector)
|
|
38
|
+
try {
|
|
39
|
+
let element = await $(elementSelector)
|
|
40
|
+
let assertionStatus = false; // Initialize status
|
|
41
|
+
try {
|
|
42
|
+
await expect(element).toHaveAttribute(attributeName, expectedText);
|
|
43
|
+
let actualText;
|
|
44
|
+
actualText = await element.getAttribute(attributeName);
|
|
45
|
+
console.log("Assertion succeeded.");
|
|
46
|
+
let annotationMessage = `Assertion passed. Attribute value: ${actualText}, Expected value: ${expectedText}.`;
|
|
47
|
+
await amendToBrowserstack(annotationMessage, "info");
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.warn("Assertion failed:", error.message);
|
|
50
|
+
let annotationMessage = `Assertion failed. Expected text: ,${expectedText}. ,${error.message}`;
|
|
51
|
+
await amendToBrowserstack(annotationMessage, "error");
|
|
52
|
+
}
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error('Error occurred while verifying text:', error);
|
|
55
|
+
let annotationMessage = `Error occurred while asserting Attribute: ${error.message}.`;
|
|
56
|
+
await amendToBrowserstack(annotationMessage, "error");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function amendToBrowserstack(annotationMessage, level) {
|
|
63
|
+
try {
|
|
64
|
+
await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
65
|
+
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error('Error occurred while verifying text:', error);
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
module.exports = { assertText, assertAttributeValue };
|
|
72
|
+
|
|
73
|
+
|
|
@@ -4,12 +4,12 @@ async function clickIfVisible(elementSelector) {
|
|
|
4
4
|
// Wait for the element to be visible
|
|
5
5
|
await driver.waitUntil(async () => {
|
|
6
6
|
console.log("Waiting for element to be visible");
|
|
7
|
-
const element = await
|
|
7
|
+
const element = await $(elementSelector);
|
|
8
8
|
isDisplayed = await element.isDisplayed();
|
|
9
9
|
console.log("Element is displayed:", isDisplayed);
|
|
10
10
|
if (isDisplayed) {
|
|
11
11
|
// Get the actual text from the element
|
|
12
|
-
const element = await
|
|
12
|
+
const element = await $(elementSelector);
|
|
13
13
|
await element.click();
|
|
14
14
|
console.log("Element is clicked successfully.");
|
|
15
15
|
return ;
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
module.exports = { scrollToEnd, scrollToLeft, scrollToBeginning, scrollRightToView, scrollDownToView, scrollToRight ,scrollIntoView};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
async function swipeleft(selector,xoffset,speedinsec) {
|
|
2
|
+
try {
|
|
3
|
+
console.log('Swiping left');
|
|
4
|
+
|
|
5
|
+
if(xoffset == null){
|
|
6
|
+
browser.swipeLeft(selector,speedinsec);
|
|
7
|
+
}else{
|
|
8
|
+
browser.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 left');
|
|
19
|
+
|
|
20
|
+
if(xoffset == null){
|
|
21
|
+
browser.swipeRight(selector,speedinsec);
|
|
22
|
+
}else{
|
|
23
|
+
browser.swipeRight(selector,xoffset,speedinsec);
|
|
24
|
+
}
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error(error.message);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Function to verify text in Android app
|
|
2
|
-
|
|
3
|
-
async function assertText(driver, elementSelector, expectedText) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
console.log("inside the assert text function" + elementSelector)
|
|
7
|
-
|
|
8
|
-
let element = await $(elementSelector)
|
|
9
|
-
let assertionStatus = false; // Initialize status
|
|
10
|
-
try {
|
|
11
|
-
await expect(element).toHaveText(expectedText);
|
|
12
|
-
assertionStatus = true; // If assertion passes, set status to true
|
|
13
|
-
} catch (error) {
|
|
14
|
-
console.warn("Assertion failed:", error.message);
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
let actualText;
|
|
18
|
-
// You can now use assertionStatus in your code
|
|
19
|
-
if (assertionStatus) {
|
|
20
|
-
console.log("Assertion succeeded.");
|
|
21
|
-
actualText = await element.getText();
|
|
22
|
-
console.log("actual text is:" + actualText);
|
|
23
|
-
let annotationMessage = `Assertion passed. Actual text: ${actualText}, Expected text: ${expectedText}.`;
|
|
24
|
-
await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"Assertion passed. Actual text:'+ actualText+ '","level": "info"}}');
|
|
25
|
-
|
|
26
|
-
} else {
|
|
27
|
-
console.log(`Assertion failed. Expected text: ,${expectedText}.`);
|
|
28
|
-
let annotationMessage = `Assertion failed. Expected text: ,${expectedText}.`;
|
|
29
|
-
await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"Assertion failed. Expected text:'+ expectedText+ '","level": "error"}}');
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.error('Error occurred while verifying text:', error);
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = assertText;
|
|
41
|
-
|
|
42
|
-
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const dbinfo = require('../api/getDBdetails');
|
|
3
|
-
const mysqlconnect = require('../db/mysqlOperations');
|
|
4
|
-
const postgreSqlConnect = require('../db/postgresOperations');
|
|
5
|
-
const getLoginToken = require('../api/loginapi');
|
|
6
|
-
// const { LocalStorage } = require('node-localstorage');
|
|
7
|
-
// global.BUFFER = new LocalStorage('./storage');
|
|
8
|
-
|
|
9
|
-
async function connectToDB(id, querytype, query) {
|
|
10
|
-
try {
|
|
11
|
-
// console.log("insude connectToDB"+id+" "+querytype+" "+query)
|
|
12
|
-
const jsondata = await dbinfo.getDbDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"), id);
|
|
13
|
-
let connectionpool = await dbtype(jsondata);
|
|
14
|
-
let result = await executeQuery(jsondata.database_type,querytype, query, connectionpool);
|
|
15
|
-
return result;
|
|
16
|
-
} catch (error) {
|
|
17
|
-
console.error('Error connectToDB', error);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function dbtype(jsondata) {
|
|
22
|
-
let connectionpool;
|
|
23
|
-
try {
|
|
24
|
-
switch (jsondata.database_type) {
|
|
25
|
-
case 'MySQL':
|
|
26
|
-
connectionpool = mysqlconnect.connectToMySQL(jsondata.host, jsondata.username, jsondata.password, jsondata.schema_name, jsondata.port_number);
|
|
27
|
-
break;
|
|
28
|
-
case 'PostgreSQL':
|
|
29
|
-
connectionpool = await postgreSqlConnect.connectToPostgreSQL(jsondata.host, jsondata.username, jsondata.password, jsondata.schema_name, jsondata.port_number);
|
|
30
|
-
break;
|
|
31
|
-
default:
|
|
32
|
-
console.log('Unknown dbtype.');
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
return connectionpool;
|
|
36
|
-
|
|
37
|
-
} catch (error) { console.error('Error dbtype', error); }
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
async function executeQuery(datatype,querytype, query, connectionpool) {
|
|
42
|
-
let finalResult;
|
|
43
|
-
try {
|
|
44
|
-
switch (querytype) {
|
|
45
|
-
case 'select':
|
|
46
|
-
if (datatype === 'MySQL') {
|
|
47
|
-
finalResult = mysqlconnect.fetchDataFromDB(connectionpool, query);
|
|
48
|
-
}else if(datatype === 'PostgreSQL'){
|
|
49
|
-
finalResult = postgreSqlConnect.fetchDataFromPostgresDB(connectionpool, query);
|
|
50
|
-
}
|
|
51
|
-
break;
|
|
52
|
-
case 'insert':
|
|
53
|
-
// connectionpool = mysqlconnect.connectTomysql(jsondata.hostname, jsondata.username, jsondata.password, jsondata.dbname, jsondata.portnumber);
|
|
54
|
-
break;
|
|
55
|
-
case 'update':
|
|
56
|
-
// connectionpool = postgreSqlConnect.fetchDataFromPostgresDB(jsondata.hostname, jsondata.username, jsondata.password, jsondata.dbname, jsondata.portnumber);
|
|
57
|
-
break;
|
|
58
|
-
default:
|
|
59
|
-
console.log('Unknown querytype.');
|
|
60
|
-
}
|
|
61
|
-
return finalResult;
|
|
62
|
-
} catch (error) { console.error('Error querytype', error); }
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// async function main() {
|
|
66
|
-
// try {
|
|
67
|
-
// BUFFER.setItem("ORGANISATION_DOMAIN_URL","devapi.frothtestops.com");
|
|
68
|
-
// //const query = 'SELECT id,EventID,NoPlate FROM store_images limit 2';
|
|
69
|
-
// const token = await getLoginToken("devapi.frothtestops.com", "subhra.subudhi@roboticodigital.com", "V2VsY29tZUAxMjM=");
|
|
70
|
-
// if (!token) {
|
|
71
|
-
// throw new Error('Login failed, no token obtained');
|
|
72
|
-
// }
|
|
73
|
-
// BUFFER.setItem("LOGIN_TOKEN",token);
|
|
74
|
-
|
|
75
|
-
// const result = await connectToDB(3, 'select', 'SELECT id,EventID,NoPlate FROM store_images limit 2');
|
|
76
|
-
// console.log("results are :" + JSON.stringify(result, null, 2));
|
|
77
|
-
// const data=JSON.stringify(result, null, 2)
|
|
78
|
-
// console.log("data is :" + result.totalNumberOfRecords);
|
|
79
|
-
// console.log("data is :" + result.records[0].id);
|
|
80
|
-
|
|
81
|
-
// } catch (err) {
|
|
82
|
-
// console.log('Error connecting to database:', err.stack);
|
|
83
|
-
// }
|
|
84
|
-
// }
|
|
85
|
-
|
|
86
|
-
// main()
|
|
87
|
-
module.exports = connectToDB;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
async function scrollDownToView(text) {
|
|
2
|
-
|
|
3
|
-
try {
|
|
4
|
-
console.log('Scrolling down until text is found');
|
|
5
|
-
await $('android=new UiScrollable(new UiSelector().scrollable(true)).scrollTextIntoView("' + text + '")');
|
|
6
|
-
await driver.pause(3000);
|
|
7
|
-
console.log('Scrolled down completed');
|
|
8
|
-
} catch (error) {
|
|
9
|
-
console.error(error.message);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
module.exports = scrollDownToView;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
async function scrollRightToView(text) {
|
|
2
|
-
|
|
3
|
-
try {
|
|
4
|
-
console.log('Scrolling to right until text is found');
|
|
5
|
-
await $('android=new UiScrollable(new UiSelector().scrollable(true)).setAsHorizontalList().scrollTextIntoView("' + text + '")');
|
|
6
|
-
await driver.pause(3000);
|
|
7
|
-
console.log('Scrolled to right completed');
|
|
8
|
-
} catch (error) {
|
|
9
|
-
console.error(error.message);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
module.exports = scrollRightToView;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
async function scrollToBeginning(maxSwipes,steps) {
|
|
2
|
-
|
|
3
|
-
try {
|
|
4
|
-
console.log('Scrolling to beginning');
|
|
5
|
-
await $('android=new UiScrollable(new UiSelector().scrollable(true)).scrollToBeginning('+maxSwipes+','+steps+')');
|
|
6
|
-
await driver.pause(3000);
|
|
7
|
-
console.log('Scrolled to beginning');
|
|
8
|
-
} catch (error) {
|
|
9
|
-
console.error(error.message);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
module.exports = scrollToBeginning;
|
|
@@ -1,13 +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
|
-
module.exports = scrollToEnd;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
async function scrollToLeft(steps) {
|
|
2
|
-
|
|
3
|
-
try {
|
|
4
|
-
console.log('Scrolling to left');
|
|
5
|
-
await $('android=new UiScrollable(new UiSelector().scrollable(true)).scrollable.setAsHorizontalList().scrollBackward('+steps+')');
|
|
6
|
-
await driver.pause(3000);
|
|
7
|
-
console.log('Scrolled to left');
|
|
8
|
-
} catch (error) {
|
|
9
|
-
console.error(error.message);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
module.exports = scrollToLeft;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
async function scrollToRight(steps) {
|
|
2
|
-
|
|
3
|
-
try {
|
|
4
|
-
console.log('Scrolling to right');
|
|
5
|
-
await $('android=new UiScrollable(new UiSelector().scrollable(true)).scrollable.setAsHorizontalList().scrollForward('+steps+')');
|
|
6
|
-
await driver.pause(3000);
|
|
7
|
-
console.log('Scrolled to right');
|
|
8
|
-
} catch (error) {
|
|
9
|
-
console.error(error.message);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
module.exports = scrollToRight;
|