2016年9月8日 星期四

018.2 Android Radio Button Example (UI test automation by Appium)

with Appium and unittest framework, there are two test cases provided for this App

  • ID: test_add_string_and_make_lowercase
    • description: [FAST] type String, click Lower, get string back
  • ID: test_add_string_and_make_uppercase
    • description: [FAST] type String, click UpperCase, get STRING back






How to Prepare Appium working environment for Windows + Python

Steps

[try #1]


1. install node JS https://nodejs.org/en/
2. install Appium http://appium.io/index.html
3. install Appium Client https://pypi.python.org/pypi/Appium-Python-Client
pip install Appium-Python-Client
pip install pytest


4. have a look on sample code before creating ours
https://github.com/appium/sample-code/tree/master/sample-code/examples/python

and then ... encountering error

[try #2]


follow steps in Setup of below
https://github.com/appium/appium/blob/master/docs/en/appium-setup/running-on-windows.md

Setup
  • 1. Download latest node and npm tools MSI (version >= 6.0). The npm and nodejs paths should be in your PATH environment variable.
  • 2. Download latest Java JDK here (accept the license agreement first). Set 'JAVA_HOME' to be your JDK path. The bin in that directory should be added to your PATH variable.
  • 3. Install the Android SDK. Set ANDROID_HOME to be your Android SDK path and add the tools and platform-tools folders to your PATH variable.

on Windows 10, SDK is installed in
C:\Users\[UserName]\AppData\Local\Android\Sdk
after setting ANDROID_HOME and PATH, type "android list" to test if everything is fine
set ANDROID_HOME=C:\\Users\\[UserName]\\AppData\\Local\\Android\Sdk
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
if we want to keep this change persistently
https://shaochien.gitbooks.io/command-line-and-environment-variable-tutorial/content/environment-variable.html

4. Install Apache Ant or use the one that comes with the Android Windows SDK in the eclipse\plugins folder. Be sure to add the folder containing Ant to your PATH variable.
5. Install Apache Maven and set the M2HOME and M2 environment variables. Set M2_HOME to the directory maven is installed in, and set M2 to the bin in that directory. Add the path you used for M2 to your PATH.
QQ: what we use ant to do? (Apache Ant is a Java library and command-line tool that help building software.)
QQ: what we use maven to do? (Apache Ant is a Java library and command-line tool that help building software.)

6. Open admin cmd
7. run command: npm install -g appium

8. run command: appium
9. Run a test from any Appium client (including Visual Studio)
Additional Setup for Android App Testing
  1. To run tests on Windows, you will need to have the Android Emulator booted or an Android Device connected that is running an AVD with API Level 17 or greater. Then run Appium on the command line (via the appium command)
  2. Within test script, change value of 'platformVersion' to correspond with emulator version (i.e. '4.4.4')
  3. Within test script, change value of 'app' to PATH('path of .apk') and ensure the entire path (including close parenthesis) is on one line

Prepare Test Case
(take a look at https://github.com/appium/sample-code/blob/master/sample-code/examples/python/android_contacts.py first)

useful functions as

  • find_element_by_id()
  • click()
  • clear()
  • send_keys()

two test cases are created for demo purpose


source code and package were updated to
https://github.com/vash-hsu/appium/tree/master/01_helloworld

Reference:

https://github.com/appium/sample-code
http://ypwalter.blogspot.tw/2015/05/appium-androidiosfirefox-os.html
http://www.qa-knowhow.com/?p=2363


沒有留言:

張貼留言