description |
---|
A step by step guide to install Maestro in Windows |
Maestro works great on Windows computers, but there are a few unique setup steps to be aware of. This guide will walk you through the end-to-end steps for getting started with Maestro on a Windows machine.
- Powershell is installed in Windows system.
- Install android studio in windows machine.
- Add ANDROID_HOME to your windows environment variable.
- To check if your ANDROID_HOME setup is correctly done, open a powershell terminal and run this command
adb --version.
- Note down the adb version.
- To check if your ANDROID_HOME setup is correctly done, open a powershell terminal and run this command
- Install Java JDK 11 and set JAVA_HOME
- Run
java --version
to check if the java is installed correctly.
- Run
- Install WSL2 (Window Subsystem for Linux)
- Install Java 11
- Install Maestro
With recent Windows 11, Microsoft have made it pretty easy to install Windows Subsystem For Linux aka WSL
In order to install WSL, open Powershell As Administrator and run following command:
wsl --install
After running the above command, follow through instructions and restart the computer.
Install Windows Terminal application for refreshing terminal experience.
Set your linux username and password (Something that you will not forget).
Run following 2 commands to update your Ubuntu system. Enter password when prompted.
sudo apt update
sudo apt upgrade
After restarting the system, open Terminal application and click on the dropdown to select Ubuntu. Type in following command:
sudo apt install openjdk-11-jdk
Installing Maestro is now just a matter of running following one command.
curl -Ls "https://get.maestro.mobile.dev" | bash
TADA!
You have successfully installed Maestro in your Windows machine 🙌
Check your maestro version using following command
maestro --version
-
Download android command line tools zip file from android official site.
-
Use the following instructions to setup android command lines correctly in your WSL2 .
- Open WSL2 terminal.
- Create a new directories in your home directory.
~ $ mkdir Android ~ $ cd Android
- Unzip the android command line tools zip file in the
android
directory using this command:unzip ~<command_line_zip_filename>.zip
- In the
android
directory:
$ mkdir tools $ mv cmdline-tools/* tools/
Note: Last command will probably give you a warning, but you don’t need the worry about that.
- Now add the following line to your
~/.bashrc file
export ANDROID_HOME=$HOME/Android export PATH=$PATH:$ANDROID_HOME/tools/bin/:$PATH
- Save your
~/.bashrc
file and exit. - Run
source ~/.bashrc
to reload the bashrc file. - Now we will install basic android utilities using following commands:
- Run
sdkmanager --list
to check if everything is working fine. - Run
sdkmanager --install "platform-tools"
to install platform tools.
- Run
- Finally add following into your
~/.bashrc
fileexport PATH=$PATH:$ANDROID_HOME/platform-tools/:$PATH
- Save your
~/.bashrc
file and exit. - Run
source ~/.bashrc
to reload the bashrc file.
- To check that everything went good, do following:
- Close and relaunch terminal
- Run
adb --version
and see that adb version is shown - Since everything is installed fresh, your WSL 2 adb version should perfectly match with windows adb version that we noted down as part of pre-requisites.
Please follow below steps to setup the ADB and make sure you are able to use android emulators with your WSL2 correctly
-
Fire up your android emulator on windows.
-
Once android emulator is up and running, open a POWERSHELL PROMPT.
-
Run this command in Powershell
adb -a -P 5037 nodaemon server
- This will start the adb server in windows host.
- Note down the IPV4 address of your windows host PC/machine.
TROUBLESHOOTING:
- Sometimes you may get
smartsockets..
error when you runadb -a -P 5037 nodaemon server
command in powershell. In that case you can do following steps:- Open task manager and kill all
adb
related processes. - If Android studio is open, close it and KEEP ONLY emulator running.
- If you see a message saying
emulator offline
, IGNORE IT. - Sometimes, firewall stops your connection with host machine. For that add a firewall rule to allow the connection or check with your organization system admin if using company machine.
- Open task manager and kill all
\
-
Note: Don't close the powershell terminal.!!
-
Now open your WSL2 terminal and run these commands.
adb kill-server
export ADB_SERVER_SOCKET=tcp:<WINDOWS_IPV4_ADDR>:5037
adb devices
You should see your connected emulator successfully now.
Yes at this point you are free to start your automation.
- Write your first flow
- How to run Maestro commands?
- You can run maestro commands in WSL2 terminal with
--host
flag. eg.- maestro --host <WINDOWS_IPV4_ADDR> test flow.yaml
- maestro --host <WINDOWS_IPV4_ADDR> studio
- You can run maestro commands in WSL2 terminal with
- Check out the full documentation
If your android emulator is not up and running in windows host, the maestro test
command fails to find installed emulator.
At this point it is recommended that you fire up emulator before running the flow
using maestro.