Mobile Automation with Appium
- Android SDK
- Android Device (configuration)
- Eclipse / Java
- Appium
Setting up Android SDK
Step 1: Open https://developer.android.com/studio/index.html
Step 2: Scroll to “Get just the command line tools”
(* You can download Android Studio also instead of SDK Tools but for testing SDK tools is sufficient)
Step 3: Download SDK Tools for respective platform
Step 4: Extract download zip
Step 5: Open “cmd” and navigate to the tools folder in SDK.
Step 6: commands
- Sdkmanager.bat --list
- Sdkmanager.bat platforms;android-26
- Sdkmanager.bat build-tools;26.0.3
- sdkmanager.bat platform-tools
Step 7: set environment variable.
- ANDROID_HOME = path to sdk folder
- PATH $ANDROID_HOME/build-tools/25.0.2;$ANDROID_HOME/platform-tools;$ANDROID_HOME/tools;
* Note - Update path according your installation
Step 8. Close all CMD and start again. Execute adb device command. If you get error for adb then check installation.
Device Set Up configuration:
- Enable developer option
- Enable usb debugging
- Connect device to computer via usb and check “adb devices” shows device connected.
Appium Set Up
- Download and Install Node.js https://nodejs.org/en/
- Open Node Js command prompt and execute below command
- npm install appium -g
- Verify appium installed with below command
- appium -v
Locating elements for native app -
Locating Android elements - Id, Xpath
IOS - Name, Xpath
Automating already existing App using Appium.
Step 1:Get package name and activity from the Application.
I. Start app. Launch screen
Ii. Execute below 2 commands
adb shell
dumpsys window windows
Search for ‘mCurrentFocus=’ Get the package name /activity name (check snap)
Package name: com.android.settings
Activity name:com.android.settings.settings
Step 2.
Set both to desired capabilities
DesiredCapabilities capabilities=new DesiredCapabilities();
capabilities.setCapability("deviceName", "Your device Name");
capabilities.setCapability("appPackage", "com.android.settings");
capabilities.setCapability("appActivity", "com.android.settings.Settings");
capabilities.setCapability("deviceName", "Your device Name");
capabilities.setCapability("appPackage", "com.android.settings");
capabilities.setCapability("appActivity", "com.android.settings.Settings");
That’s all you need…Now you can create driver instance and use it for automation.
No comments:
Post a Comment