Monday, June 20, 2016

xCode to launch various simulators to run tests on emulator / or real devices

Let’s begin with Appium app installation on mac -

Appium app provides ready to run version of appium server. Install appium client and start appium server as described in following steps -

Install latest Appium client for ios from - http://appium.io/downloads.html (You may have issues downloading this file from chrome, FF seems to work without issues)

Once download is over then Control-click appium.dmg > open with > DiskImageMounter.app

DMG is a apple disk image. The disk image will be mounted.

Then look for the mounted disk image in your finder (cmd + space), It will appear there. Right click and open. You should also drag it to Applications folder so that you can search it in finder (command + tab) in future.

After app verification you will see a warning > Click Open

You will see a warning for Appium authorization to run iOS simulator > Select Yes

Click the Launch button to launch appium inspector. If everything goes ok then you should see Welcome message

Once you launch an app on emulator then you can click on magnifying glass (appium inspector) to verify application elements.

By default appium app runs the bundled version of appium. If you are running a newest version of appium from source then select it under Preference > Use External Appium Package checkbox

If you use xCode version lower than 6.0.0 then you would encounter following error when running test -

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Tried to use an iOS simulator with xcode version 5.1.1 but only Xcode version 6.0.0 and up are supported (WARNING: The server did not provide any stacktrace information)

2.1. if you are not able to find sdk path in your mac system, do the following steps,Open finder->select Go option on top menu -> select Go to Folder option -> it will popup a window with a textfield: /Users/your_system_username/Library/Android/sdk/ -> now open platform-tools folder and paste your copied .apk file,

Now open terminal and type the following: cd Library/Android/sdk/platform-tools

execute the following in your terminal: ./adb install yourapkfilename.apk

4.1. if you get the following error message: error: no devices found - waiting for device - follow the step 5.

Run your emulator from Android Studio, once emulator active then repeat step 4, you will see the success message on your terminal.

You need to know app package and app activity to be able to run test on mobile app.

If app is already installed on device/emulator then you can find name of app package and app activity from catlog, start -

adb catlog

Launch app on emulator/device

Find the appPackage and appActivity from cat log, for ex following are the appPackage and appActivity for calculator app on my android emulator -

You can also find app package and app activity from within appium app. Click android icon on appium app > select App Path checkbox > Choose apk file. After a while you will see Package and Launch Activity (app activity) on Android Settings window -

You can also use an app called apkinfo to find out app package and app activity for an app installed on device