Posts

Connect Android device wirelessly (over Wi-Fi) to your machine

Image
When you want to run tests on android devices, you have to connect your phone(s) to your test running machine. Adding and removing different devices to your machine is a bit of a headache and it looks messy as well. So if you want to connect your android device to your machine over Wi-Fi (wirelessly) you can do the following.

First connect your device to your test machineFrom the command prompt/terminal, run the command adb devices  (you should see the connected device to your machine) Make sure that your device and your test machine are in the same network.Run the command  adb tcpip 5555 You will see a message saying “restarting in TCP mode port: 5555”Disconnect the device from your machineGet the IP address of your phone (Go to Settings > Wi-Fi > Your Connected Network > IP Address)You may have to long tap your network name to see the IP Address, depending on your android versionRun the following command to connect adb to your device over Wi-Fi using the given IP Address adb…

Start & Stop Appium Server Programmatically using Java (MAC OSX)

Image
Appium is widely used for mobile automation these days. You have to have your Appium server up and running before you can run your automated Appium tests. Most of the times, the test engineers ensure that the Appium server is running before they start executing the test suite. But this arrangement won’t work if you want to run your Appium tests in Continuous Integration/Deployment.

In this post, we will see how to start & stop Appium server programmatically using Java. This code is for Mac OSX (10.10). In next article we will see how to start & stop Appium server programmatically using Java on windows.

So here is the code Create a class called AppiumServer and paste the code mentioned below
Loaded using https://gist.github.com/rightqa/81e60d6540098817480b...
In your test class, before you set driver capabilities, start the Appium server like the following

Appiumserver server=new Appiumserver(); 
System.out.println("---- Starting Appium server ----"); 
server.startServe…

Install & Setup Android SDK and ADB on Mac OSX

Image
We have already seen how to install and configure Android SDK on windows. In this post we will see how to install and configure Android SDK and ADB on Mac OSX. We are using Yosemite (Mac OSX 10.10) while writing this post.
Go to http://developer.android.com/sdk/installing/index.htmlClick and download “STAND_ALONE SDK TOOLS”  The downloaded file will be a zip file with name like “android-sdk_r24.3.3-macosx.zip” (NOTE: version number could be different based on when you are downloading) Unzip the downloaded file and rename it with something shorter, say “android-sdk”Move the “android-sdk” directory to a location of your choiceThe Android SDK archive initially contains only the basic SDK tools. It does not contain an Android platform or any third-party libraries. We need to download them.To download the necessary filesStart your terminalNavigate to the location where you have your android-sdk folder (#5 above)Navigate to tools folderWrite “android” and hit returnAndroid SDK manager will s…

Sending keyboard input via ADB to your android device

Image
Say you are writing an Appium test for Android and you are required to interact with native Android keyboard. Let’s take a test scenario
Launch the applicationTap on the Search bar/box/buttonEnter the search termTap on Enter key on native Android keyboard. How would you do this? We will focus on the last action of tapping “Enter” key on Android keyboard.
It could be simply done by using something called “SendKeyEvent”
driver.sendKeyEvent(key);

Now, how do you know about the key you want to pass to “SendKeyEvent”? Below is the list (table) of keys for your reference.

To verify that it works in your script, you can check them using ADB. Assuming you have your Android SDK properly installed and configured, you can do the following.
Open command prompt (on windows)Use command “adb devices” to make sure that the devices you want to interact with is available in the list returned by adbThen you can endter “adb shell input keyevent <keycode>” use <keycode> from the below table as pe…

Appium desired capabilities for iOS

In our previous post, we saw Appium desired capabilities specific to Android. Here we have listed all the desired capabilities for iOS. Most of them are optional capabilities, but these will come handy when you are writing full blown test automation for iOS. Appium desired capabilities - iOS OnlyCapabilityDescriptionValuescalendarFormat(Sim-only) Calendar format to set for the iOS Simulatore.g. gregorianbundleIdBundle ID of the app under test. Useful for starting an app on a real device or for using other caps which require the bundle ID during test startup. To run a test on a real device using the bundle ID, you may omit the 'app' capability, but you must provide 'udid'.e.g. io.appium.TestAppudidUnique device identifier of the connected physical devicee.g. 1ae203187fc012glaunchTimeoutAmount of time in ms to wait for instruments before assuming it hung and failing the sessione.g. 20000locationServicesEnabled(Sim-only) Force location services to be either on or off. De…

Appium desired capabilities for Android

In our previous post, we understood about Appium desired capabilities. Appium supports Android, iOS and FirefoxOS platforms, hence there are some platform specific desired capabilities.

Here we have listed all the desired capabilities for Android. Most of them are optional capabilities, but these will come handy when you are writing full blown test automation for Android.
CapabilityDescriptionValuesappActivityActivity name for the Android activity you want to launch from your packageMainActivity, .SettingsappPackageJava package of the Android app you want to runcom.example.android.myApp,
com.android.settingsappWaitActivityActivity name for the Android activity you want to wait forSplashActivityappWaitPackageJava package of the Android app you want to wait forcom.example.android.myApp,
com.android.settingsdeviceReadyTimeoutTimeout in seconds while waiting for device to become ready5androidCoverageFully qualified instrumentation class. Passed to -w in adb shell am instrument -e coverag…

Appium Desired Capabilities

We have seen how to write Appium test for Android. Actually it’s NOT an actual test. If you see in that post, we run it as a JAVA APPLICATION. But before we write an actual test (or a meaningful test) we need to understand more about Appium desired capabilities.

Here we will explain what are Appium desired capabilities and why do we use them. But before we dive in the details, we will have to brush up our understanding about Appium architecture. You can read detailed post here.

We know that the Appium server does the following (in addition to other things that it does)
Receives connections from a client and creates a session So what is a Session? (In terms of Appium automation) Automation is always performed in the context of a session. When a client initiates a session with Appium server, it basically sends a POST/session request to the Appium server, with a JSON object called the ‘desired capabilities’. Appium server receives the connection and start up the automation session. Appium…