Cybersecurity, Mobile Integration Testing

Cybersecurity Mobile Integration Testing

Install Android Studio

Android Studio Phone Emulator

Setup Emulator

If the AVD Manager is already present in the Tools Menu, this section is not necessary.

  1. Start New Project
  2. Empty new project with no steps, and accept the default everything
  3. Go to Settings and search for "AVD" to help ensure it shows up in the proper menus
    1. Select it
    2. Accept the changes
  4. Go To Tools --> AVD Manager
  5. Create Virtual Device
  6. Phone type as Pixel 2 (or another if desired)
  7. Choose Pie API (or another if desired)
    1. Accept all the things
    2. Download it before proceeding
    3. Downloading and installing may take some time
    4. Click Finish
  8. Verify Config (Can rename to something meaningful like "name01")
  9. Finish the setup
  10. Now it is available!
  11. Push the Play Button in the Virtual Device Description if it is not already running
  12. Open the phone

Test an APK

  1. Procure the APK with which to test
  2. Start the Emulator Phone (directions to create are provided above in Setup Emulator)
  3. Drag and Drop the APK onto the phone
    1. Will install to the phone
    2. Windows Save location will be similar to C:\Users\username\.android\avd\name01.avd
  4. Open the Application just installed
    1. Left Click "Home" and "Swipe Up" to find it
    2. Click the Application
    3. Can add to home screen by dragging it there

Integration Testing with Robot Framework

About Robot Framework

Robot Framework Installation

*** Note: Install these items as Administrator to avoid future issues ***

Use Appium to Inspect APK Elements

C:\Users\username\AppData\Local\Android\Sdk\platform-tools>adb devices 
List of devices attached 
device-name   device
C:\Users\username\AppData\Local\Android\Sdk\platform-tools>adb shell 
generic_x86_arm:/ $ 
generic_x86_arm:/ $ dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'  
    mCurrentFocus=Window{abc123 u0 com.android.calculator2/com.android.calculator2.Calculator}  
    mFocusedApp=AppWindowToken{def456 token=Token{ghi789 ActivityRecord{jkl012 u0 com.android.calculator2/.Calculator t16}}} 
generic_x86_arm:/ $
  • Use all of this info to help fill out this section in the Appium Search
{  
    "platformName": "Android",  
    "platformVersion": "9.0",  
    "deviceName": "device-name",  
    "automationName": "UiAutomator2",  
    "appPackage": "com.android.calculator2",  
    "appActivity": "com.android.calculator2.Calculator" 
}

Run a Robot File

After inspecting an App, a Robot file can be created.

Robot Files are named as filename.robot.

Robot Files are run as robot filename.robot.

This is a sample Robot File for the Calculator App (named testcalc.robot):

*** Settings *** 
Documentation  Test Cases for evaluation of a proper setup with 
...   RobotFramework, AppiumLibrary, and Emulated Android Phone 
...   
...   This will solve the equation 2+4 and present 6 as the answer 
...   
...   Various Click styles are presented for examples 
...   
...   A screenshot will be saved to the working directory before closing 

Library     AppiumLibrary   

*** Variables *** 
${LOCAL_APPIUM_SERVER}    http://localhost:4723/wd/hub 

*** Keywords *** 
Open the Application
    Open Application    ${LOCAL_APPIUM_SERVER}    platformName=android    platformVersion=9.0
        ...    deviceName=emulator-5554    automationName=uiautomator2
        ...    appPackage=com.android.calculator2    appActivity=com.android.calculator2.Calculator 

Enter the Equation
    Click Element    id=com.android.calculator2:id/digit_2
    Click Element    accessibility_id=plus
    Click Element    xpath=//android.widget.LinearLayout[@content-desc="Numbers and basic operations"]/android.view.ViewGroup[1]/android.widget.Button[4] 

Solve the Equation
    Click Element At Coordinates    600    1600  

Close the Application
    Capture Page Screenshot
    Close Application  

*** Test Cases *** 
Valid Open and Close the Calculator
    Open the Application
    Enter the Equation
    Solve the Equation
    Close the Application
 

This can be run using robot testcalc.robot. In the directory where this file is present, the following files will be created:

  • appium-screenshot-1.png
  • log.html
  • output.xml
  • report.html





Keywords:security, developer, sdlc, cybersecurity, devops, secdevops   Doc ID:106384
Owner:Michelle P.Group:University of Illinois Technology Services
Created:2020-10-05 14:27 CDTUpdated:2020-10-08 09:19 CDT
Sites:University of Illinois Technology Services
Feedback:  0   0