Skip to content

Commit a21f556

Browse files
authored
Add guide to install custom chrome version on Android Emulator. (#367)
1 parent 14713c4 commit a21f556

File tree

3 files changed

+274
-3
lines changed

3 files changed

+274
-3
lines changed

docs/guide/mobile-web-testing/override-device-dimensions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ To reset the device dimensions back to original, you can again call the `browser
118118
</a>
119119
</div>
120120
<div class="next">
121-
<a href="/guide/extending-nightwatch/adding-custom-commands.html">
121+
<a href="/guide/mobile-web-testing/upgrade-chrome-on-emulator.html">
122122
<div class="d-flex flex-column">
123123
<span class="smallT">Next Page</span>
124-
<span class="bigT">Define custom commands</span>
124+
<span class="bigT">Upgrade Chrome on Android Emulator</span>
125125
</div>
126126
<span>→</span>
127127
</a>
Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
---
2+
title: Upgrade Chrome Browser on Android Emulator
3+
description: Learn how to upgrade Google Chrome browser on Android emulators for mobile web testing.
4+
---
5+
6+
<div class="page-header"><h1>Upgrade Chrome Browser on Android Emulator</h1></div>
7+
8+
### Overview
9+
10+
Android emulators come with an older version of Google Chrome browser pre-installed. For mobile web testing, you may need to install a newer version of Chrome to match your testing requirements or to access modern web features.
11+
12+
This guide covers two methods to upgrade Chrome browser on your Android emulator:
13+
14+
1. **Using Google Play Store** - Easiest method, but requires a system image with Play Store support
15+
2. **Using APK Mirror** - More flexible, allows installing specific Chrome versions
16+
17+
### Prerequisites
18+
19+
- Android SDK and AVD Manager installed
20+
- `ANDROID_HOME` environment variable set
21+
22+
If your system does not meet the above prerequisites, run the below command to setup android emulator.
23+
<div class="sample-test"><i>Terminal</i><pre class="line-numbers"><code>npx @nightwatch/mobile-helper android</code></pre></div>
24+
25+
### Method 1: Upgrade Chrome via Google Play Store
26+
27+
This is the simplest method, but it requires an Android Virtual Device (AVD) that includes Google Play Store support.
28+
29+
#### Step 1: Install System Image with Play Store
30+
31+
You need to install a system image that includes Google Play Store. These system images are typically named `google_apis_playstore`.
32+
33+
<div class="sample-test"><i>Terminal</i><pre class="line-numbers"><code>npx @nightwatch/mobile-helper android install --system-image</code></pre></div>
34+
35+
When prompted:
36+
- **Select the API level**: Choose your desired Android version (e.g., `android-34: Android 14`)
37+
- **Select the system image type**: Choose `google_apis_playstore` (not `google_apis`)
38+
- **Select the architecture**: Choose based on your system (e.g., `x86_64` or `arm64-v8a`)
39+
40+
Example output:
41+
<pre class="line-numbers"><code>Checking the value of ANDROID_HOME environment variable...
42+
✔ ANDROID_HOME is set to '/Users/shubhamkumar/Library/Android/sdk' (taken from .env)
43+
44+
? Select the API level for system image: android-34: Android 14
45+
? Select the system image type for android-34: google_apis_playstore
46+
? Select the architecture for the system image: x86_64
47+
48+
Installing system image: system-images;android-34;google_apis_playstore;x86_64
49+
50+
[=======================================] 100% Unzipping... x86_64/vendor.img</code></pre>
51+
52+
#### Step 2: Create AVD with Play Store System Image
53+
54+
Create a new AVD using the system image you just installed:
55+
56+
<div class="sample-test"><i>Terminal</i><pre class="line-numbers"><code>npx @nightwatch/mobile-helper android install --avd</code></pre></div>
57+
58+
When prompted:
59+
- **Enter a name for the AVD**: Give it a descriptive name (e.g., `nightwatch-android-14`)
60+
- **Select the system image to use for AVD**: Choose the `google_apis_playstore` system image you installed
61+
- **Select the device type**: Choose a device (e.g., `Pixel`)
62+
- **Select the device profile**: Choose a profile (e.g., `pixel_7`)
63+
64+
Example output:
65+
<pre class="line-numbers"><code>Checking the value of ANDROID_HOME environment variable...
66+
✔ ANDROID_HOME is set to '/Users/shubhamkumar/Library/Android/sdk' (taken from .env)
67+
68+
? Enter a name for the AVD: nightwatch-android-14
69+
? Select the system image to use for AVD: system-images;android-34;google_apis_playstore;x86_64
70+
? Select the device type for AVD: Pixel
71+
? Select the device profile for AVD: pixel_7
72+
73+
Creating AVD...</code></pre>
74+
75+
#### Step 3: Connect to Emulator and Update Chrome
76+
77+
1. Connect to your emulator using the mobile helper:
78+
<div class="sample-test"><i>Terminal</i><pre class="line-numbers"><code>npx @nightwatch/mobile-helper android connect --emulator</code></pre></div>
79+
When prompted, select the AVD you created (e.g., `nightwatch-android-14`).
80+
Example output:
81+
<pre class="line-numbers"><code>Checking the value of ANDROID_HOME environment variable...
82+
✔ ANDROID_HOME is set to '/Users/shubhamkumar/Library/Android/sdk' (taken from .env)
83+
Connected Emulators:
84+
1. udid/deviceId: emulator-5554 / state: device (online)
85+
? Select the AVD to connect: nightwatch-android-14
86+
Connecting to AVD: nightwatch-android-14</code></pre>
87+
2. **Sign in to Google Play Store** with your Google account
88+
3. Open the Play Store app on the emulator
89+
4. Search for "Google Chrome"
90+
5. Click **Update** to install the latest version of Chrome
91+
92+
<div class="alert alert-info">
93+
<strong>Note:</strong> The first time you use Play Store on an emulator, you'll need to complete the Google account sign-in process. This is a one-time setup. You can remove your Google account later.
94+
</div>
95+
96+
### Method 2: Upgrade Chrome via APK Mirror
97+
98+
This method allows you to install a specific version of Chrome without requiring Play Store support. It's useful when you need a particular Chrome version or when using system images without Play Store.
99+
100+
#### Step 1: Download Chrome APK from APK Mirror
101+
102+
1. Visit [APKMirror](https://www.apkmirror.com/apk/google-inc/chrome/)
103+
2. Select the desired Chrome version
104+
3. **Important**: Download the compatible variant based on your system image architecture:
105+
- For `x86_64` system images: Download `x86_64` variant
106+
- For `arm64-v8a` system images: Download `arm64-v8a` variant
107+
- For `armeabi-v7a` system images: Download `armeabi-v7a` variant
108+
109+
<div class="alert alert-warning">
110+
<strong>Important:</strong> Make sure to download the correct architecture variant. Installing an incompatible APK will fail or cause issues.
111+
</div>
112+
113+
APKMirror typically provides `.apkm` files (Android App Bundle) which need to be extracted before installation.
114+
115+
#### Step 2: Extract the APKM File
116+
117+
Extract the downloaded `.apkm` file to get the individual APK files:
118+
119+
<div class="sample-test"><i>Terminal</i><pre class="line-numbers"><code>unzip /path/to/com.android.chrome_VERSION_apkmirror.com.apkm -d chrome_bundle</code></pre></div>
120+
121+
This will extract all APK files into the `chrome_bundle` directory.
122+
123+
Example:
124+
<pre class="line-numbers"><code>unzip ~/Downloads/com.android.chrome_144.0.7559.109-755910933_26lang_5feat_9f83e13585051a7774655d06b7189713_apkmirror.com.apkm -d chrome_bundle</code></pre>
125+
126+
#### Step 3: Upgrade Chrome APK on Emulator
127+
128+
Use the mobile helper to install the extracted APK files:
129+
130+
<div class="sample-test"><i>Terminal</i><pre class="line-numbers"><code>npx @nightwatch/mobile-helper android.adb install-multiple chrome_bundle/*.apk</code></pre></div>
131+
132+
Make sure your emulator is running before executing this command.
133+
134+
Example output:
135+
<pre class="line-numbers"><code>Checking the value of ANDROID_HOME environment variable...
136+
✔ ANDROID_HOME is set to '/Users/shubhamkumar/Library/Android/sdk' (taken from .env)
137+
138+
Success</code></pre>
139+
140+
<div class="alert alert-info">
141+
<strong>Note:</strong> The `install-multiple` command is used because Chrome APKM bundles contain multiple APK files (base APK + split APKs for different architectures/languages) that need to be installed together.
142+
</div>
143+
144+
### Verify Chrome Installation
145+
146+
After installation, verify that Chrome is installed correctly:
147+
148+
1. Open the emulator
149+
2. Look for the Chrome app icon in the app drawer
150+
3. Launch Chrome and check the version:
151+
- Open Chrome menu (three dots)
152+
- Go to **Settings****About Chrome**
153+
- Verify the version matches what you installed
154+
155+
### Troubleshooting
156+
157+
#### Issue: Play Store not available
158+
159+
**Solution**: Use Method 2 (APK Mirror) instead, which doesn't require Play Store support.
160+
#### Issue: APK installation fails with "INSTALL_FAILED_INVALID_APK"
161+
162+
###### **Possible causes**:
163+
- Architecture mismatch between APK and system image
164+
- Corrupted APK file
165+
- Incomplete extraction of APKM bundle
166+
167+
###### **Solution**:
168+
- Verify you downloaded the correct architecture variant
169+
- Re-download the APK file
170+
- Ensure all APK files from the bundle are extracted
171+
172+
173+
#### Issue: Chrome crashes after installation
174+
175+
###### **Possible causes**:
176+
- Version incompatibility with Android version
177+
- Missing dependencies
178+
179+
###### **Solution**:
180+
- Try a different Chrome version
181+
- Ensure you're using a compatible Android API level
182+
- Check if the system image has all required components
183+
184+
#### Issue: Cannot find Chrome after installation
185+
186+
###### **Solution**:
187+
- Restart the emulator
188+
- Check if Chrome appears in Settings → Apps
189+
- Try installing again with `--force` flag if available
190+
191+
#### Issue: No ChromeDriver found for Chrome version
192+
193+
**Error message**: `No Chromedriver found that can automate Chrome 'X.X.X'. You could also try to enable automated chromedrivers download as a possible workaround.`
194+
195+
###### **Possible causes**:
196+
- The installed Chrome version is not in Appium's ChromeDriver mappings
197+
- Appium cannot automatically download the matching ChromeDriver version
198+
199+
###### **Solution**: You have two options:
200+
201+
202+
###### **Option 1: Download ChromeDriver manually**
203+
204+
1. Check your Chrome version on the emulator (Settings → About Chrome)
205+
2. Visit the [Appium ChromeDriver mappings](https://github.com/appium/appium-chromedriver/blob/master/config/mapping.json) to find the corresponding ChromeDriver version
206+
3. Download the ChromeDriver binary for your system from the [ChromeDriver downloads page](https://chromedriver.chromium.org/downloads)
207+
4. Set the path to ChromeDriver in your Nightwatch configuration using the `appium:chromedriverExecutable` capability:
208+
209+
<div class="sample-test"><i>nightwatch.conf.js</i><pre class="hide-indicator line-numbers"><code>desiredCapabilities: {
210+
browserName: 'Chrome',
211+
platformName: 'Android',
212+
'appium:options': {
213+
automationName: 'UiAutomator2',
214+
avd: 'nightwatch-android-14',
215+
// Path to your downloaded ChromeDriver executable
216+
chromedriverExecutable: '/path/to/chromedriver'
217+
}
218+
}</code></pre></div>
219+
220+
Alternatively, you can set it directly in `desiredCapabilities`:
221+
222+
<div class="sample-test"><i>nightwatch.conf.js</i><pre class="hide-indicator line-numbers"><code>desiredCapabilities: {
223+
browserName: 'Chrome',
224+
platformName: 'Android',
225+
'appium:chromedriverExecutable': '/path/to/chromedriver',
226+
'appium:options': {
227+
automationName: 'UiAutomator2',
228+
avd: 'nightwatch-android-14'
229+
}
230+
}</code></pre></div>
231+
232+
###### **Option 2: Update Chrome to latest version**
233+
234+
Update Chrome on your emulator to the latest version, which typically has better Appium support and automatic ChromeDriver download capabilities.
235+
236+
237+
### Best Practices
238+
239+
1. **Match Architecture**: Always ensure the Chrome APK architecture matches your system image architecture
240+
2. **Version Compatibility**: Use Chrome versions that are compatible with your Android API level
241+
3. **ChromeDriver Compatibility**: Consider using the latest Chrome version for better Appium/ChromeDriver support. Older or specific Chrome versions may require manual ChromeDriver installation
242+
4. **Test After Installation**: Always verify Chrome works correctly and that ChromeDriver is available before running your Nightwatch tests
243+
244+
### Next Steps
245+
246+
After upgrading Chrome on your emulator, you can now configure Nightwatch to use the emulator for mobile web testing.
247+
248+
For more information on mobile web testing with Nightwatch, see the [Mobile Web Testing Guide](https://github.com/nightwatchjs/mobile-helper-tool/blob/main/docs/mobile-web-testing.md).
249+
250+
<div class="doc-pagination pt-40">
251+
<div class="previous">
252+
<a href="/guide/mobile-web-testing/override-device-dimensions.html">
253+
<span>←</span>
254+
<div class="d-flex flex-column">
255+
<span class="smallT">Back</span>
256+
<span class="bigT">Override Device Dimensions</span>
257+
</div>
258+
</a>
259+
</div>
260+
<div class="next">
261+
<a href="/guide/extending-nightwatch/adding-custom-commands.html">
262+
<div class="d-flex flex-column">
263+
<span class="smallT">Next Page</span>
264+
<span class="bigT">Define custom commands</span>
265+
</div>
266+
<span>→</span>
267+
</a>
268+
</div>
269+
</div>
270+

src/includes/guide-sidebar.ejs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ const navItems = [
188188
collapseId: 'mobiletesting-collapse',
189189
links: [
190190
{ title: 'Use Nightwatch with Appium', url: '/guide/mobile-web-testing/with-appium.html' },
191-
{ title: 'Override device dimensions', url: '/guide/mobile-web-testing/override-device-dimensions.html' }
191+
{ title: 'Override device dimensions', url: '/guide/mobile-web-testing/override-device-dimensions.html' },
192+
{ title: 'Upgrade Chrome on emulator', url: '/guide/mobile-web-testing/upgrade-chrome-on-emulator.html' }
192193
]
193194
}
194195
]

0 commit comments

Comments
 (0)