-
Notifications
You must be signed in to change notification settings - Fork 3
/
smartuiAndroid.js
65 lines (53 loc) · 1.69 KB
/
smartuiAndroid.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
const wd = require("wd");
/**
* Username to be used for running the test.
*/
const username = process.env.LT_USERNAME || "YOUR_LT_USERNAME";
/**
* The access key to be used for running test test.
*/
const accessKey = process.env.LT_ACCESS_KEY || "YOUR_LT_ACCESS_KEY";
/**
* Capabilities to be passed while running the test.
*/
const desiredCapabilities = {
app: "lt://proverbial-android", // Enter the app_url here
build: "NodeJS - Android_App",
name: "Sample Test NodeJS-Android",
deviceName: "Galaxy S20",
isRealMobile: true,
platformName: "android",
platformVersion: "11",
video: true,
visual: true,
"smartUI.project": "Real-Device-Project-Android", // Enter your smartUI Project name
};
const driver = wd.promiseRemote(
`https://${username}:${accessKey}@mobile-hub.lambdatest.com/wd/hub`
);
const DEFAULT_TIMEOUT = 10000;
/**
* Run an Android test.
*/
async function runSmartuiAndroidTest() {
try {
await driver.init(desiredCapabilities);
await driver.waitForElementById("color", DEFAULT_TIMEOUT);
await (await driver.elementById("color"));
await driver.waitForElementById("Text", DEFAULT_TIMEOUT);
await (await driver.elementById("Text"));
await driver.waitForElementById("toast", DEFAULT_TIMEOUT);
await (await driver.elementById("toast"));
await driver.execute(`smartui.takeScreenshot=<Name of your Screenshot>`);
console.log("Screenshot Captured");
// Quit driver after successful execution
await driver.quit();
console.log("Driver quit successfully.");
} catch (e) {
console.error(e);
// Quit driver in case of error
await driver.quit();
console.log("Driver quit after error.");
}
}
runSmartuiAndroidTest();