Skip to content

Commit e37aeb3

Browse files
authored
Merge pull request #20 from browserstack/java_versions
Creating dedicated directories for java7 and java8
2 parents 2f1f069 + 8932035 commit e37aeb3

13 files changed

+791
-174
lines changed

README.md

Lines changed: 2 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1,172 +1,2 @@
1-
# java-appium-app-browserstack
2-
3-
This repository demonstrates how to run Appium Java tests on BrowserStack App Automate.
4-
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-
### For java-client 8.0.0 and above
33-
34-
- Any BrowserStack capability passed outside bstack:options will not be honoured \
35-
[Browserstack Capability Builder](https://www.browserstack.com/app-automate/capabilities?tag=w3c)
36-
37-
- AppiumBy is available with java-client 8.0.0 as MobileBy is depreceated . For java-client < 8.0.0, MobileBy can be used.
38-
39-
- DefaultGenericMobileElement class has been removed completely together with its descendants (MobileElement, IOSElement, AndroidElement etc.). Use WebElement instead.
40-
41-
- WebDriverWait constructor requires time to be passed as a type Duration. So with java-client 8.0.0, pass wait time as a new Duration
42-
**java-client v-7.0.0**
43-
```
44-
WebElement searchElement = (WebElement) new WebDriverWait(driver, 30)
45-
```
46-
47-
**java-client v-8.0.0**
48-
```
49-
import java.time.Duration;
50-
WebElement searchElement = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30))
51-
```
52-
53-
Refer this for tracking changes in java-client 8.0.0 documentation - [v7-to-v8-migration-guide](https://github.com/appium/java-client/blob/master/docs/v7-to-v8-migration-guide.md#mobileelement)
54-
55-
### Run your first test :
56-
57-
**1. Upload your Android or iOS App**
58-
59-
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 :
60-
61-
```
62-
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
63-
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
64-
-F "file=@/path/to/apk/file"
65-
```
66-
67-
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.
68-
69-
**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).
70-
71-
**2. Configure and run your first test**
72-
73-
Open `BrowserStackSample.java` file in the `android` directory or `ios` directory :
74-
75-
- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings)
76-
77-
- Replace `bs://<app-id>` with the URL obtained from app upload step
78-
79-
- Set the device and OS version
80-
81-
- If you have uploaded your own app update the test case
82-
83-
- To run the test, use the following command in the base directory :
84-
85-
- For Android test, run
86-
87-
```cmd
88-
mvn test -P android-first-test
89-
```
90-
91-
- For iOS test, run
92-
93-
```cmd
94-
mvn test -P ios-first-test
95-
```
96-
97-
- 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)
98-
99-
---
100-
101-
### Use Local testing for apps that access resources hosted in development or testing environments :
102-
103-
**1. Upoad your Android or iOS App**
104-
105-
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 :
106-
107-
```
108-
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
109-
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
110-
-F "file=@/path/to/apk/file"
111-
```
112-
113-
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.
114-
115-
**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).
116-
117-
**2. Configure and run your local test**
118-
119-
Local Testing is a BrowserStack feature that helps you test mobile apps that access resources hosted in development or testing environments during automated test execution
120-
121-
**i. Setup Browserstack Local Testing connection :**
122-
123-
Check the releases page to download the binary / native application [Browserstack Local Releases](https://www.browserstack.com/docs/local-testing/releases-and-downloads)
124-
125-
- Option 1
126-
- Use Browserstack Local Binary - [Local Binary](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/local-testing)
127-
- Option 2
128-
- Use Browserstack native application - [Local Native App](https://www.browserstack.com/docs/local-testing/local-app-upgrade-guide)
129-
130-
131-
NOTE : If you're unable to run the LocalTesting Binary / Native application due to Apple permission issues, go to \
132-
```
133-
System preferences -> Security and privacy -> General -> Allow app
134-
```
135-
136-
**ii. Open `BrowserStackSampleLocal.java` file in the `android` or `ios` directory :**
137-
138-
- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings)
139-
140-
- Replace `bs://<app-id>` with the URL obtained from app upload step
141-
142-
- Set the device and OS version
143-
144-
- 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.
145-
146-
- If you have uploaded your own app update the test case
147-
148-
- To run the test, use the following command in the base directory :
149-
150-
- For Android test, run
151-
152-
```cmd
153-
mvn test -P android-local-test
154-
```
155-
156-
- For iOS test, run
157-
158-
```cmd
159-
mvn test -P ios-local-test
160-
```
161-
162-
- 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)
163-
164-
165-
## Integration with other Java frameworks
166-
167-
- [JUnit](https://github.com/browserstack/junit-appium-app-browserstack)
168-
- [TestNg](https://github.com/browserstack/testng-appium-app-browserstack)
169-
170-
## Getting Help
171-
172-
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).
1+
| [Using Java 7 client with MJSONWP protocol](./java_7) | [Using Java 8 client with w3c protocol](./java_8) |
2+
|------------------------------------------------------ | ------------------------------------------------- |

java_7/README.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
| Using Java 7 client with MJSONWP protocol | [Using Java 8 client with w3c protocol](../java_8) |
2+
|------------------------------------------ | -------------------------------------------------- |
3+
4+
# java-appium-app-browserstack
5+
6+
This repository demonstrates how to run Appium Java tests on BrowserStack App Automate.
7+
8+
## Setup
9+
10+
### Requirements
11+
12+
1. Java 8+ (JDK)
13+
14+
- If Java is not installed, follow these instructions:
15+
- For Windows, download latest java version from [here](https://java.com/en/download/) and run the installer executable
16+
- 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/)
17+
18+
2. Maven
19+
20+
- If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi)
21+
- For installation, follow the instructions [here](https://maven.apache.org/install.html)
22+
23+
### Install the dependencies
24+
25+
To install the dependencies, run the following command in the project's base folder
26+
27+
```cmd
28+
mvn clean install
29+
```
30+
31+
## Getting Started
32+
33+
Getting Started with Appium tests in Java on BrowserStack couldn't be easier!
34+
35+
### Run your first test :
36+
37+
**1. Upload your Android or iOS App**
38+
39+
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 :
40+
41+
```
42+
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
43+
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
44+
-F "file=@/path/to/apk/file"
45+
```
46+
47+
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.
48+
49+
**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).
50+
51+
**2. Configure and run your first test**
52+
53+
Open `BrowserStackSample.java` file in the `android` directory or `ios` directory :
54+
55+
- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings)
56+
57+
- Replace `bs://<app-id>` with the URL obtained from app upload step
58+
59+
- Set the device and OS version
60+
61+
- If you have uploaded your own app update the test case
62+
63+
- To run the test, use the following command in the base directory :
64+
65+
- For Android test, run
66+
67+
```cmd
68+
mvn test -P android-first-test
69+
```
70+
71+
- For iOS test, run
72+
73+
```cmd
74+
mvn test -P ios-first-test
75+
```
76+
77+
- 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)
78+
79+
---
80+
81+
### Use Local testing for apps that access resources hosted in development or testing environments :
82+
83+
**1. Upoad your Android or iOS App**
84+
85+
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 :
86+
87+
```
88+
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
89+
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
90+
-F "file=@/path/to/apk/file"
91+
```
92+
93+
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.
94+
95+
**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).
96+
97+
**2. Configure and run your local test**
98+
99+
Open `BrowserStackSampleLocal.java` file in the `android` or `ios` directory :
100+
101+
- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings)
102+
103+
- Replace `bs://<app-id>` with the URL obtained from app upload step
104+
105+
- Set the device and OS version
106+
107+
- 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.
108+
109+
- If you have uploaded your own app update the test case
110+
111+
- To run the test, use the following command in the base directory :
112+
113+
- For Android test, run
114+
115+
```cmd
116+
mvn test -P android-local-test
117+
```
118+
119+
- For iOS test, run
120+
121+
```cmd
122+
mvn test -P ios-local-test
123+
```
124+
125+
- 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)
126+
127+
128+
## Integration with other Java frameworks
129+
130+
- [JUnit](https://github.com/browserstack/junit-appium-app-browserstack)
131+
- [TestNg](https://github.com/browserstack/testng-appium-app-browserstack)
132+
133+
## Getting Help
134+
135+
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).

0 commit comments

Comments
 (0)