Prepare your Mac for (mobile) test automation

The Mac mini I use for mobile test automation got stuck at booting up after an update of OSX (thanks Apple) and there was no way to recover (I didn't have a time machine backup). Maybe I could have found a clever way to restore access to the Macintosh HD, but I decided to just go for the reinstall instead and make it a bit more detailed this time than in one of my previous blogposts.


Installations

OSX updates (1)

First make sure you have installed all OSX (security) updates. Via the app store > updates > check for updates.

Install Xcode

  1. Navigate to the App Store 
  2. Search for Xcode 
  3. Login with Apple ID 
  4. Get/Install (if asked, also install the command line tools)
`xcode-select -p` will show the current path.
To change it, you can do what they also described on this Appium GitHub topic:
  • sudo xcode-select -s /Applications/Xcode.app 
  • Quit Appium, Restart Appium and try again

Install Android Studio

  1. Download the installer
  2. Open the dmg 
  3. Drag Android Studio to the Applications folder 
  4. Open android studio 
    • Don't import anything > next
    • Custom installation
    • Select the theme you like
    • Select Android Vitual Device 
    • Emulator settings leave default, next 
    • Finish
Start Android studio, open the SDK manager and install all needed SDK's. Now start a new project, just next > next > next > finish. Look at the bottom and wait for `Gradle` to finish synchronising. Open the terminal and build to see if there are any errors to resolve. This is mandatory since the Android Virtual Device icon (top right corner) might otherwise stay grated out.

Once all that is done you need to add ANDROID_HOME to your bash_profile to make sure we can use the ADB command.
  • nano ~/.bash_profile
  • export ANDROID_HOME=<your_path_to_the_android_sdk>
  • export PATH=$ANDROID_HOME/platform-tools:$PATH
  • export PATH=$ANDROID_HOME/tools:$PATH
If you forgot to write down the location, open Android studio and find it in the preferences (Appearance & Behaviour > System Settings > Android SDK).
More info can be found on this stackoverflow topic.

OSX updates (2)

Software update (again)
  • App Store >> check for more updates (Xcode / command line / etc) 
  • Install all updates that are shown

Install Java

Download the Java SDK from the oracle website and install it.

Install Homebrew + Carthage

Download and install via the instructions on the brew website.
After that, you can install Carthage via the terminal `brew install carthage`.

Install Ruby + gems

  • Install Ruby via the terminal `brew install ruby`
    • Install the lapis_lazuli gem via the terminal `gem install 'lapis_lazuli'` (will also take care of cucumber, water, selenium-webdriver and some other needed gems)
    • Install the appium_lib gem via the terminal `gem install 'appium_lib'`

Install Appium

Download the latest version from the Git website. Installing is as simple as just opening the dmg, and drag the Appium into the Applications folder.
OR via the terminal
  • brew install node
  • npm install -g appium
  • npm install wd

Download latest Chrome driver

Download the latest Chrome driver for Android (if needed, which depends on the the version of Chrome on the Android phone and on the the version that comes with Appium, see running Appium below).

Next steps

Run the iOS simulator

  1. Start Xcode
  2. Xcode menu
  3. Open developer tools
  4. Simulator >> will start iPhone X with iOS 11.3

Run the Android Emulator

  1. Start Android studio
  2. Click on the AVD manager logo in the top right corner
  3. If needed add a new device that is matching the capabilities you need
    • I always choose one with play store so I can update the Chrome app easily
    • It takes some time to download other images (e.g. Android 8.0, 7.1, 7.0)
    • If not sure which one to take, go for the recommended
  4. Start up a device (e.g. Nexus 5 X with Android 8.1)
  5. Log into the Google Play Store
  6. Update the apps (or at least the Chrome app)
  7. Enable Developer Options and make sure that debugging option is enabled (not sure if this was needed with an emulator, but with a real device this for sure is needed so I always enable this by default)

Run Appium

Open Appium desktop app and start a simple server (for test).
Or open a simple server via terminal 'appium &'
For running Appium with a certain chrome driver version see stackoverflow.

Final words

With this step by step guide, you should now be able to start you mobile tests as described in my previous blogpost. In case you're stuck with anything, give me a ping and I'll try to help out.

Comments

Popular posts from this blog

PowerShell - How to overcome Azure VM's fixed resolution limitation

TA Basics: Website Test Automation on mobile devices via Appium server

TA: Who doesn't like proxies? Me!