12
TABLE CONTENT 1. SUPPORT PLATFORMS ............................................................................................................... 2 2. INSTALLATION GUIDE ............................................................................................................... 2 2.1. Install Android SDK............................................................................................................. 2 2.2. Setup environment................................................................................................................ 3 2.2.1. Setup Android environment........................................................................................... 3 2.2.2. Set developer environment on Android ......................................................................... 5 2.3. Install the WebDriver APK on device or emulator .............................................................. 5 3. REMOTE DEBUGGING FOR ANDOID...................................................................................... 6 3.1. Remote debugging Chrome.................................................................................................. 7 3.2. Remote debugging Firefox ................................................................................................... 8 3.2.1. Enable remote debugging on Firefox of Android device. ............................................. 8 3.2.2. Enable remote debugging on Firefox of the desktop..................................................... 9 4. DELOY AUTOMATION TEST ON ANDROID........................................................................ 11

TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

TABLE CONTENT

1. SUPPORT PLATFORMS ............................................................................................................... 2

2. INSTALLATION GUIDE ............................................................................................................... 2

2.1. Install Android SDK............................................................................................................. 2

2.2. Setup environment................................................................................................................ 3

2.2.1. Setup Android environment........................................................................................... 3

2.2.2. Set developer environment on Android ......................................................................... 5

2.3. Install the WebDriver APK on device or emulator .............................................................. 5

3. REMOTE DEBUGGING FOR ANDOID ...................................................................................... 6

3.1. Remote debugging Chrome .................................................................................................. 7

3.2. Remote debugging Firefox ................................................................................................... 8

3.2.1. Enable remote debugging on Firefox of Android device. ............................................. 8

3.2.2. Enable remote debugging on Firefox of the desktop ..................................................... 9

4. DELOY AUTOMATION TEST ON ANDROID ........................................................................ 11

Page 2: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

1. SUPPORT PLATFORMS

In the sense of automation testing for Android mobile device, Android WebDriver (in android-server.apk) allows to run automated end-to-end tests that ensure your site works correctly when viewed from the Android browser. Run the tests on Android require environment supports as below:

• Windows XP (32-bit), Vista (32- or 64-bit), or Windows 7 (32- or 64-bit) • JDK 7u60 and JRE 7 and later in http://java.oracle.com (JDK version as same as JRE

version)

• Android SDK Tools: depend on Android version to download Android SDK, see revision platforms. For example:

o Android SDK r19 or higher is required for Android 4.4 o Android SDK r18 or higher is required for Android 4.3 o …

• Android WebDriver: o android-server-2.16.apk support to Android 2.2–2.2.3 Froyo (API level 8) o The lastest version (android-server-2.21.0.apk, android-server-2.38.0.apk )

support to � Android 2.3.x Gingerbread (API level 9 ~ 10) � Android 3.x Honeycomb (API level 11 ~ 13) � Android 4.0.x Ice Cream Sandwich (API level 14 ~ 15) � Android 4.1 ~ 4.3 Jelly Bean (API level 16 ~ 18) � Android 4.4 KitKat (API level 19)

Note that: - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is difficult to detect elements on website for automation

• For installing mobile emulator: o Genymotion 2.2.2 with VirtualBox (this version includes Oracle VirtualBox 4.2.12)

2. INSTALLATION GUIDE

2.1. Install Android SDK

- Install Java SE Development Kit (JDK)

Go to http://java.oracle.com > Downloads > Java SE > JDK

- Install Android SDK

Page 3: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

Go to http://developer.android.com/sdk/index.html > View all download and size> SDK Tools only > Select the compressed file with your platform

Extract the downloaded package to the folder name “Android-sdk-xxx” which have platforms, add-ons and tools

Open android file in tools folders to active Android SDK Manager, stick the newest version of Android (e.g. Android 4.4.2 - API19) and install them.

Note: install “Google USB driver” to directly run test case on device.

2.2. Setup environment

2.2.1. Setup Android environment

Run the test on emulators or real devices for phone and tablets

a. Set up the Emulator (using Geneymotion)

Registry a free account on http://www.genymotion.com/ and active new account by email, then login with new account and download a package Genymotion(with VirtualBox)

Go to Geneymotion application via login your account. Create a new virtual device by choosing the device (HTC One, Xperia Z, Samsung Galaxy S4, Nexus, tablet…) and clicking next to download it.

Page 4: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

After finishing the download, double click your virtual machine to deploy device.

b. Set up the device

Simply connect your Android device through USB to your machine.

Install the mobile driver on desktop to detect your device (e.g. need LGUnitedMobileDriver for LG devices).

Page 5: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

2.2.2. Set developer environment on Android

On emulator/device, go to Settings > Developer options > Turn on USB Debugging

On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number 7 times. Return to the previous screen to find Developer options and check USB debugging.

2.3. Install the WebDriver APK on device or emulator

To get the desktop and the Android device talking to each other using the adb command-line tool in Android SDK. Every device or emulator has a serial ID. Take the command line to go to android_sdk/platform-tools and run this command to get the serial ID of the device or emulator you want to use:

adb devices Ex: root>adb devices

Download the Android server from https://code.google.com/p/selenium/downloads/list . To install the application do: (recommend version android-server-2.21.0.apk)

adb -s <serialId> -e install -r android-server.apk Ex: root>adb –s 192.168.56.101:5555 -e install –r a ndroid-server-2.21.0.apk

Page 6: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

Then it appears a Webdriver application on device/emulator. Start the Android WebDriver application through the UI of the device or by running this command:

adb -s <serialId> shell am start -a android.intent. action.MAIN -n org.openqa.selenium.android.app/.MainActivity

Make the android server available at http://localhost:8080/wd/hub/status from the host machine by a terminal type:

adb -s <serialId> forward tcp:8080 tcp:8080 Ex: root>adb -s 192.168.56.101:5555 forward tcp:808 0 tcp:8080

3. REMOTE DEBUGGING FOR ANDOID

Page 7: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

3.1. Remote debugging Chrome (limitation to Android 4 and up , Chrome 32 and up)

Recommend this debug because it’s easy to check and detect the xpath of objects on Android than Remote debugging Firefox.

Check all available devices which connect to the desktop by command line

adb devices

Call remote Chrome devtools to detect objects of website on your device:

Root>adb -s <serialId> forward tcp:9222 localabstra ct:chrome_devtools_remote

Ex: root>adb -s 192.168.56.101:5555 forward tcp:922 2 localabstract:chrome_devtools_remote

To enable USB discovery in Chrome, on your desktop Chrome browser, go to chrome://inspect. Alternatively, to get to the same screen, you can select Chrome menu > Tools > Inspect Devices. Confirm that Discover USB Devices is checked:

Page 8: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

There will be presented with the set of thumbnails for pages currently open in tabs on your mobile Chrome. Choose inspect link at the page you would like to debug and it will show the corresponding developer tools.

To get xpath of any element on page, on tab Elements of Developer Tools, Enter Ctrl +F > type keywords to find the element which you want to detect > right click at the right element and choose “Copy XPath”.

3.2. Remote debugging Firefox (limitation to Android 2.2 and up, Firefox 24 and up)

3.2.1. Enable remote debugging on Firefox of Android device.

Type about:config on address bar of Firefox for Android, type "devtools" into the search box and press the Search key. You'll see all the devtools preferences. Find the devtools.debugger.remote-enabled preference, and press "Toggle". Open the menu, select "Settings", then "Developer tools" (on some Android devices you may need to select "More" to see the "Settings" option). Check the "Remote debugging" box:

Come back the Firefox of Android device and go to the site which you want to debug (e.g. http://google.com )

Page 9: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

3.2.2. Enable remote debugging on Firefox of the desktop

On the desktop, remote debugging is enabled in Developer Tools. On menu bar, choose Tools > Web Developers > Toggle Tools, then it show the DevTools in the end of page, choose Settting icon and check "Enable remote debugging":

Check all available devices which connect to the desktop by command line

adb devices

Firefox Developer Tools can debug remote devices by default port 6000. So make connection to remote devices via default port:

adb -s <serialId> forward tcp:6000 tcp:6000

On Firefox of desktop, choose Tools > Web Developers > Connect > set the suitable value and click Connect, then Firefox browser of remote devices will show the message:

Press OK

Page 10: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

Open the Developer Tools for remote site by choosing the link of your site on Connect page

Page 11: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

4. DELOY AUTOMATION TEST ON ANDROID

Note: if URL is IP address, you must install Certificate of site for Devices

1. Install certificate:

1.1. Export Certificate of site on FF:

- Click on Lock icon > click on More Information button - Choose Security tab > View Certificate - Choose Details tab > click on Export - At Save as type field: choose “X.509 Certificate with chain (PEM) (*.crt;*.pem)” and

click Save button. 1.2. Import Certificate into Devices:

- Store Certificate file which have just exported into Devices - Go to Setting > Security > Install from SD card - Go to Folder where you store Certificate file and click on it to install - Enter Certificate Name: enter info you like ☺, credential use: choose wifi, click on

OK - Here, system require Pass for devices, don’t worry, let do it. We will remove it in the

moment - On Security tab, choose Screen lock > choose None. Done - Security > Trusted credentials > User. Check to make sure Certificate imported

2. Configure default driver in Capybara

1. Go to \RWFramework\Configuration 2. Open spec_helper.rb (by notepad++ or other editor) 3. Config driver to Android Webdriver

Page 12: TABLE CONTENT - ccim.com...Android 4.4 KitKat (API level 19) Note that : - there is an emulator bug on Gingerbread that might cause WebDriver to crash - android-server-2.38.0.apk is

4. Save and close the file spec_helper.rb