forked from LambdaTest/LT-appium-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAndroid.js
96 lines (93 loc) · 2.66 KB
/
Android.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const wd = require("wd");
/**
* Username to be used for running the test.
*/
const username = process.env.LT_USERNAME || "username";
/**
* The access key to be used for running test test.
*/
const accessKey = process.env.LT_ACCESS_KEY || "accessKey";
const buildName = process.env.LT_BUILD_NAME;
const appId = process.env.LT_APP_ID;
const deviceName = process.env.LT_DEVICE_NAME;
const deviceVersion = process.env.LT_DEVICE_VERSION;
/**
* Capabilities to be passed while running the test.
*/
const desiredCapabilities = {
app: appId, // Enter the 'app_url' here.
build: buildName,
name: "Sample Test NodeJS",
deviceName: deviceName,
isRealMobile: true,
platformName: "android",
platformVersion: deviceVersion,
video: true,
visual: true,
tunnel: true
};
const driver = wd.promiseRemote(
`https://${username}:${accessKey}@mobile-hub.lambdatest.com/wd/hub`
);
const DEFAULT_TIMEOUT = 10000;
/**
* Run an android test.
*/
async function runAndroidTest() {
try {
console.log(desiredCapabilities)
driver
.init(desiredCapabilities)
.then(function () {
return driver.waitForElementById("color", DEFAULT_TIMEOUT);
})
.then(function (colorButton) {
return colorButton.click();
})
.then(function () {
return driver.waitForElementById("Text", DEFAULT_TIMEOUT);
})
.then(function (text) {
text.click();
return driver.waitForElementById("toast", DEFAULT_TIMEOUT);
})
.then(function (toast) {
toast.click();
return driver.waitForElementById("notification", DEFAULT_TIMEOUT);
})
.then(function (notification) {
notification.click();
return driver.waitForElementById("geoLocation", DEFAULT_TIMEOUT);
})
.then(function (geoLocation) {
geoLocation.click();
return driver.waitForElementById("buttonPage", DEFAULT_TIMEOUT);
})
.then(function (Home) {
Home.click();
return driver.waitForElementById("speedTest", DEFAULT_TIMEOUT);
})
.then(function (speedTest) {
speedTest.click();
return driver.waitForElementById("webview", DEFAULT_TIMEOUT);
})
.then(function (Browser) {
Browser.click();
return driver.waitForElementById("url", DEFAULT_TIMEOUT);
})
.then(function (url) {
url.type("https://www.ifconfig.me");
return driver.waitForElementById("find", DEFAULT_TIMEOUT);
})
.then(function (find) {
find.click();
console.log("Test completed");
driver.quit();
});
} catch (e) {
console.log(e)
driver.quit();
}
console.log("Test is running....");
}
runAndroidTest();