Skip to content

Commit 608f628

Browse files
new test script (#1)
* added test case and configs * added new test script * test fix * renamed directories * App URL changed * changed app url * webview -> Browser * deleted sample-test.js * Updated readme file * Delete package.json * Delete package.json Co-authored-by: Ankit Agarwal <86770951+codeSolicitor@users.noreply.github.com>
1 parent f2c7df8 commit 608f628

File tree

7 files changed

+361
-1
lines changed

7 files changed

+361
-1
lines changed

README.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,78 @@
11
# LT-appium-nodejs-webdriverio
2-
LT-appium-nodejs-webdriverio repo
2+
Sample repo to run app automation on real device on LambdaTest.
3+
4+
## Pre-requisites
5+
6+
- Download and install **NodeJS**. You should be having **NodeJS v6** or newer. Click [here](https://nodejs.org/en/) to download.
7+
- Make sure you are using the latest version of **JavaScript**.
8+
- Install **npm** from the official website by clicking [here](https://www.npmjs.com/).
9+
10+
### Clone The Sample Project
11+
12+
**Step-1:** Clone the LambdaTest’s [LT-appium-nodejs-webdriverio](https://github.com/LambdaTest/LT-appium-nodejs-webdriverio) and navigate to the code directory as shown below:
13+
14+
```bash
15+
git clone https://github.com/LambdaTest/LT-appium-nodejs-webdriverio
16+
cd LT-appium-nodejs-webdriverio
17+
```
18+
19+
### Setting Up Your Authentication
20+
21+
Make sure you have your LambdaTest credentials with you to run test automation scripts on LambdaTest. To obtain your access credentials, [purchase a plan](https://billing.lambdatest.com/billing/plans) or access the [Automation Dashboard](https://appautomation.lambdatest.com/).
22+
23+
**Step-2:** Set LambdaTest `Username` and `Access Key` in environment variables.
24+
25+
```bash
26+
export LT_USERNAME="YOUR_LAMBDATEST_USERNAME"
27+
export LT_ACCESS_KEY="YOUR_LAMBDATEST_ACCESS_KEY"
28+
```
29+
30+
### Upload Your Application
31+
32+
**Step-3:** Upload your **_iOS_** application (.ipa file) or **_android_** application (.apk file) to the LambdaTest servers using our **REST API**. You need to provide your **Username** and **AccessKey** in the format `Username:AccessKey` in the **cURL** command for authentication. Make sure to add the path of the **appFile** in the cURL request. Here is an example cURL request to upload your app using our REST API:
33+
34+
For Linux / MacOS:
35+
36+
```bash
37+
curl -u "YOUR_LAMBDATEST_USERNAME":"YOUR_LAMBDATEST_ACCESS_KEY" \
38+
--location --request POST 'https://manual-api.lambdatest.com/app/upload/realDevice' \
39+
--form 'name="Android_App"' \
40+
--form 'appFile=@"/Users/macuser/Downloads/proverbial_android.apk"'
41+
```
42+
For Windows:
43+
44+
```bash
45+
curl -u "YOUR_LAMBDATEST_USERNAME":"YOUR_LAMBDATEST_ACCESS_KEY" -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" -F "appFile=@"/Users/macuser/Downloads/proverbial_android.apk""
46+
```
47+
> Note:
48+
> - If you do not have any **.apk** or **.ipa** file, you can run your sample tests on LambdaTest by using our sample :link: [Android app](https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_android.apk) or sample :link: [iOS app](https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_ios.ipa).
49+
> - Response of above cURL will be a **JSON** object containing the `App URL` of the format - <lt://APP123456789123456789> and will be used in the next step.
50+
51+
### Executing The Tests
52+
53+
If you are using an **iOS** app, the cURL command will generate an app URL for the corresponding iOS app and install the same for running the tests. You can either use our sample :link: [iOS app](https://prod-mobile-artefacts.lambdatest.com/assets/docs/proverbial_ios.ipa) or upload your own app as discussed earlier.
54+
55+
**Step-4:** Navigate to the corresponding directory based on your app.
56+
57+
- For android:
58+
```bash
59+
cd android-sample
60+
```
61+
- For ios:
62+
```bash
63+
cd ios-sample
64+
```
65+
66+
**Step-5:** Install the required dependencies using the following command:
67+
68+
```bash
69+
npm i
70+
```
71+
72+
**Step-6:** Execute the following command to run your test on LambdaTest platform:
73+
74+
```bash
75+
npm run single
76+
```
77+
> Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on the :link: [LambdaTest App Automation Dashboard](https://appautomation.lambdatest.com/build).
78+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
exports.config = {
2+
user: process.env.LT_USERNAME || "YOUR_USERNAME",
3+
key: process.env.LT_ACCESS_KEY || "YOUR_ACCESS_KEY",
4+
5+
updateJob: false,
6+
specs: ["./../specs/android-test.js"],
7+
exclude: [],
8+
9+
commonCapabilities: {
10+
build: "NodeJS WebdriverIO Android",
11+
name: "Sample Parallel Test - WebDriverIO",
12+
isRealMobile: true,
13+
app: "YOUR_APP_URL",
14+
},
15+
16+
capabilities: [
17+
{
18+
platformName: "Android",
19+
deviceName: "Galaxy S9",
20+
platformVersion: "10",
21+
},
22+
{
23+
platformName: "Android",
24+
deviceName: "Galaxy S9 Plus",
25+
platformVersion: "10",
26+
},
27+
],
28+
29+
logLevel: "info",
30+
coloredLogs: true,
31+
screenshotPath: "./errorShots/",
32+
baseUrl: "",
33+
waitforTimeout: 10000,
34+
connectionRetryTimeout: 90000,
35+
connectionRetryCount: 3,
36+
path: "/wd/hub",
37+
hostname: "beta-hub.lambdatest.com",
38+
port: 80,
39+
40+
framework: "mocha",
41+
mochaOpts: {
42+
ui: "bdd",
43+
timeout: 20000,
44+
},
45+
};
46+
47+
exports.config.capabilities.forEach(function (caps) {
48+
for (var i in exports.config.commonCapabilities)
49+
caps[i] = caps[i] || exports.config.commonCapabilities[i];
50+
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
exports.config = {
2+
user: process.env.LT_USERNAME || "YOUR_USERNAME",
3+
key: process.env.LT_ACCESS_KEY || "YOUR_ACCESS_KEY",
4+
5+
updateJob: false,
6+
specs: ["./../specs/android-test.js"],
7+
exclude: [],
8+
9+
capabilities: [
10+
{
11+
build: "NodeJS WebDriverIO Android",
12+
name: "Sample Test - WebDriverIO",
13+
isRealMobile: true,
14+
platformName: "Android",
15+
deviceName: "Galaxy S9",
16+
platformVersion: "10",
17+
app: "YOUR_APP_URL", //Set your APP URL
18+
},
19+
],
20+
21+
logLevel: "info",
22+
coloredLogs: true,
23+
screenshotPath: "./errorShots/",
24+
baseUrl: "",
25+
waitforTimeout: 10000,
26+
connectionRetryTimeout: 90000,
27+
connectionRetryCount: 3,
28+
path: "/wd/hub",
29+
hostname: "beta-hub.lambdatest.com",
30+
port: 80,
31+
32+
framework: "mocha",
33+
mochaOpts: {
34+
ui: "bdd",
35+
timeout: 20000,
36+
},
37+
};

ios-sample/ios-parallel.conf.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
exports.config = {
2+
user: process.env.LT_USERNAME || "YOUR_USERNAME",
3+
key: process.env.LT_ACCESS_KEY || "YOUR_ACCESS_KEY",
4+
5+
updateJob: false,
6+
specs: ["./../specs/ios-test.js"],
7+
exclude: [],
8+
9+
maxInstances: 10,
10+
commonCapabilities: {
11+
build: "NodeJS WebdriverIO iOS",
12+
name: "Sample Parallel Test - WebDriverIO",
13+
isRealMobile: true,
14+
app: "YOUR_APP_URL", //Set your APP URL
15+
},
16+
17+
capabilities: [
18+
{
19+
deviceName: "iPhone 13 Pro",
20+
platformVersion: "15",
21+
platformName: "iOS",
22+
},
23+
{
24+
deviceName: "iPhone 13 Pro Max",
25+
platformVersion: "15",
26+
platformName: "iOS",
27+
},
28+
],
29+
30+
logLevel: "info",
31+
coloredLogs: true,
32+
screenshotPath: "./errorShots/",
33+
baseUrl: "",
34+
waitforTimeout: 10000,
35+
connectionRetryTimeout: 90000,
36+
connectionRetryCount: 3,
37+
path: "/wd/hub",
38+
hostname: "beta-hub.lambdatest.com",
39+
port: 80,
40+
41+
framework: "mocha",
42+
mochaOpts: {
43+
ui: "bdd",
44+
timeout: 20000,
45+
},
46+
};
47+
48+
// Code to support common capabilities
49+
exports.config.capabilities.forEach(function (caps) {
50+
for (var i in exports.config.commonCapabilities)
51+
caps[i] = caps[i] || exports.config.commonCapabilities[i];
52+
});

ios-sample/ios-single.conf.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
exports.config = {
2+
user: process.env.LT_USERNAME || "YOUR_USERNAME",
3+
key: process.env.LT_ACCESS_KEY || "YOUR_ACCESS_KEY",
4+
5+
updateJob: false,
6+
specs: ["./../specs/ios-test.js"],
7+
exclude: [],
8+
9+
capabilities: [
10+
{
11+
build: "NodeJS WebDriverIO iOS",
12+
name: "Sample Test - WebDriverIO",
13+
isRealMobile: true,
14+
deviceName: "iPhone 13 Pro",
15+
platformVersion: "15",
16+
platformName: "iOS",
17+
app: "YOUR_APP_URL", //Set your APP URL
18+
},
19+
],
20+
21+
logLevel: "info",
22+
coloredLogs: true,
23+
screenshotPath: "./errorShots/",
24+
baseUrl: "",
25+
waitforTimeout: 10000,
26+
connectionRetryTimeout: 90000,
27+
connectionRetryCount: 3,
28+
path: "/wd/hub",
29+
hostname: "beta-hub.lambdatest.com",
30+
port: 80,
31+
32+
framework: "mocha",
33+
mochaOpts: {
34+
ui: "bdd",
35+
timeout: 20000,
36+
},
37+
};

specs/android-test.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
describe("Proverbial APK", () => {
2+
it("Changes color", async () => {
3+
var color = await $("id=color");
4+
await color.waitForDisplayed({ timeout: 30000 });
5+
await color.click();
6+
await color.click();
7+
});
8+
9+
it("Changes text", async () => {
10+
var text = await $("id=Text");
11+
await text.waitForDisplayed({ timeout: 30000 });
12+
await text.click();
13+
});
14+
15+
it("Toast", async () => {
16+
var toast = await $("id=toast");
17+
await toast.waitForDisplayed({ timeout: 30000 });
18+
await toast.click();
19+
});
20+
21+
it("Notification", async () => {
22+
var nf = await $("id=notification");
23+
await nf.waitForDisplayed({ timeout: 30000 });
24+
await nf.click();
25+
});
26+
27+
it("Geolocation", async () => {
28+
var geo = await $("id=geoLocation");
29+
await geo.waitForDisplayed({ timeout: 30000 });
30+
await geo.click();
31+
32+
driver.back();
33+
});
34+
35+
it("SpeedTest", async () => {
36+
var st = await $("id=speedTest");
37+
await st.waitForDisplayed({ timeout: 30000 });
38+
await st.click();
39+
40+
await browser.pause(10000);
41+
driver.back();
42+
});
43+
44+
it("Browser", async () => {
45+
var browser = await $("id=Browser");
46+
await browser.waitForDisplayed({ timeout: 30000 });
47+
await browser.click();
48+
49+
let el7 = await $("id=url");
50+
await el7.click();
51+
await el7.setValue("https://www.lambdatest.com/");
52+
driver.back();
53+
});
54+
});

specs/ios-test.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
describe("Proverbial APK", () => {
2+
it("Changes color", async () => {
3+
var color = await $("id=color");
4+
await color.waitForDisplayed({ timeout: 30000 });
5+
await color.click();
6+
await color.click();
7+
});
8+
9+
it("Changes text", async () => {
10+
var text = await $("id=Text");
11+
await text.waitForDisplayed({ timeout: 30000 });
12+
await text.click();
13+
});
14+
15+
it("Toast", async () => {
16+
var toast = await $("id=toast");
17+
await toast.waitForDisplayed({ timeout: 30000 });
18+
await toast.click();
19+
});
20+
21+
it("Notification", async () => {
22+
var nf = await $("id=notification");
23+
await nf.waitForDisplayed({ timeout: 30000 });
24+
await nf.click();
25+
});
26+
27+
it("Geolocation", async () => {
28+
var geo = await $("id=geoLocation");
29+
await geo.waitForDisplayed({ timeout: 30000 });
30+
await geo.click();
31+
32+
driver.back();
33+
});
34+
35+
it("SpeedTest", async () => {
36+
var st = await $("id=speedTest");
37+
await st.waitForDisplayed({ timeout: 30000 });
38+
await st.click();
39+
40+
await browser.pause(10000);
41+
driver.back();
42+
});
43+
44+
it("Browser", async () => {
45+
var browser = await $("id=Browser");
46+
await browser.waitForDisplayed({ timeout: 30000 });
47+
await browser.click();
48+
49+
let el7 = await $("id=url");
50+
await el7.click();
51+
await el7.setValue("https://www.lambdatest.com/");
52+
driver.back();
53+
});
54+
});

0 commit comments

Comments
 (0)