Skip to content

Commit ef74b65

Browse files
authored
Merge pull request #13 from kn-neeraj/new_maven_project
Created new maven project and updated first test script for Android and iOS according to QSG Python spec.
2 parents 9543190 + e7f7f02 commit ef74b65

11 files changed

+535
-197
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.png
2+
target/
3+
local.log
4+
.idea
5+
*.iml
6+
**/.DS_Store
7+
**/.settings
8+
.classpath
9+
.project
10+

README.md

Lines changed: 128 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,132 @@
1-
App Automate Java Samples
2-
---------------------
1+
# java-appium-app-browserstack
32

4-
This repository contains code for Automated Native App tests using Appium in Java. Please feel free to clone the repo and use the example code.
3+
This repository demonstrates how to run Appium Java tests on BrowserStack App Automate.
54

6-
For frameworks integration with BrowserStack, refer to their individual repositories -
5+
## Setup
6+
7+
### Requirements
8+
9+
1. Java 8+
10+
11+
- If Java is not installed, follow these instructions:
12+
- For Windows, download latest java version from [here](https://java.com/en/download/) and run the installer executable
13+
- For Mac and Linux, run `java -version` to see what java version is pre-installed. If you want a different version download from [here](https://java.com/en/download/)
14+
15+
2. Maven
16+
17+
- If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi)
18+
- For installation, follow the instructions [here](https://maven.apache.org/install.html)
19+
20+
### Install the dependencies
21+
22+
To install the dependencies, run the following command in the project's base folder
23+
24+
```cmd
25+
mvn clean install
26+
```
27+
28+
## Getting Started
29+
30+
Getting Started with Appium tests in Java on BrowserStack couldn't be easier!
31+
32+
### Run your first test :
33+
34+
**1. Upload your Android or iOS App**
35+
36+
Upload your Android app (.apk or .aab file) or iOS app (.ipa file) to BrowserStack servers using our REST API. Here is an example cURL request :
37+
38+
```
39+
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
40+
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
41+
-F "file=@/path/to/apk/file"
42+
```
43+
44+
Ensure that @ symbol is prepended to the file path in the above request. Please note the `app_url` value returned in the API response. We will use this to set the application under test while configuring the test later on.
45+
46+
**Note**: If you do not have an .apk or .ipa file and are looking to simply try App Automate, you can download and test using our [sample Android app](https://www.browserstack.com/app-automate/sample-apps/android/WikipediaSample.apk) or [sample iOS app](https://www.browserstack.com/app-automate/sample-apps/ios/BStackSampleApp.ipa).
47+
48+
**2. Configure and run your first test**
49+
50+
Open `BrowserStackSample.java` file in the `android` directory or `ios` directory :
51+
52+
- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings)
53+
54+
- Replace `bs://<app-id>` with the URL obtained from app upload step
55+
56+
- Set the device and OS version
57+
58+
- If you have uploaded your own app update the test case
59+
60+
- To run the test, use the following command in the base directory :
61+
62+
- For Android test, run
63+
64+
```cmd
65+
mvn test -P android-first-test
66+
```
67+
68+
- For iOS test, run
69+
70+
```cmd
71+
mvn test -P ios-first-test
72+
```
73+
74+
- You can access the test execution results, and debugging information such as video recording, network logs on [App Automate dashboard](https://app-automate.browserstack.com/dashboard)
75+
76+
---
77+
78+
### Use Local testing for apps that access resources hosted in development or testing environments :
79+
80+
**1. Upoad your Android or iOS App**
81+
82+
Upload your Android app (.apk or .aab file) or iOS app (.ipa file) that access resources hosted on your internal or test environments to BrowserStack servers using our REST API. Here is an example cURL request :
83+
84+
```
85+
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
86+
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
87+
-F "file=@/path/to/apk/file"
88+
```
89+
90+
Ensure that @ symbol is prepended to the file path in the above request. Please note the `app_url` value returned in the API response. We will use this to set the application under test while configuring the test later on.
91+
92+
**Note**: If you do not have an .apk or .ipa file and are looking to simply try App Automate, you can download and test using our [sample Android Local app](https://www.browserstack.com/app-automate/sample-apps/android/LocalSample.apk) or [sample iOS Local app](https://www.browserstack.com/app-automate/sample-apps/ios/LocalSample.ipa).
93+
94+
**2. Configure and run your local test**
95+
96+
Open `BrowserStackSampleLocal.java` file in the `android` or `ios` directory :
97+
98+
- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings)
99+
100+
- Replace `bs://<app-id>` with the URL obtained from app upload step
101+
102+
- Set the device and OS version
103+
104+
- Ensure that `browserstack.local` capability is set to `true`. Within the test script, there is code snippet that automatically establishes Local Testing connection to BrowserStack servers using Java binding for BrowserStack Local.
105+
106+
- If you have uploaded your own app update the test case
107+
108+
- To run the test, use the following command in the base directory :
109+
110+
- For Android test, run
111+
112+
```cmd
113+
mvn test -P android-local-test
114+
```
115+
116+
- For iOS test, run
117+
118+
```cmd
119+
mvn test -P ios-local-test
120+
```
121+
122+
- You can access the test execution results, and debugging information such as video recording, network logs on [App Automate dashboard](https://app-automate.browserstack.com/dashboard)
123+
124+
125+
## Integration with other Java frameworks
7126
8127
- [JUnit](https://github.com/browserstack/junit-appium-app-browserstack)
9-
- [TestNg](https://github.com/browserstack/testng-appium-app-browserstack)
128+
- [TestNg](https://github.com/browserstack/testng-appium-app-browserstack)
129+
130+
## Getting Help
131+
132+
If you are running into any issues or have any queries, please check [Browserstack Support page](https://www.browserstack.com/support/app-automate) or [get in touch with us](https://www.browserstack.com/contact?ref=help).

android/BrowserStackAndroid.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

android/LocalSampleAndroid.java

Lines changed: 0 additions & 72 deletions
This file was deleted.

android/README.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

ios/README.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)