Selenium_Selenium for Android: MonkeyTalk Installation and Use

來源:互聯網
上載者:User

This guide will explain how to do automated testing on the android emulator using Gorilla Logic MonkeyTalk. To do this you must have a working installation of Eclipse IDE, ADT Plugin, Android sdk, an avd image file and a test project to work with. I'm using
the SimpleCalc program fromMobileTutsPlus but any simple app will do to get this working. I'd advise using a completed working app so you know that any errors are not issues with the app 
Prerequisite tutorials

"Eclipse with Android SDK - Installation Guide" from this blog. You'll may need this to help set up your environment. It also contains some "other topics" such as how to load an android app into Eclipse, install a .apk on the emulator, how to run the app etc.
You will need

Windows 7 x64 - All instructions are for Windows users.
Gorilla Logic - MonkeyTalk (free open source download)
Android SDK (free open source download)
Eclipse IDE with ADT plugin installed (other steps below).
As before, follow the Eclipse tutorial I did if you are unsure about how to configure these programs. 
Reason for using MonkeyTalk

Android testing can potentially be a lot easier and faster with record / playback facilities and scripting. We can write our own scripts by hand but this is a time consuming task which requires repeating whenever the AUT changes.

Having a record / playback facility enables us to create a script as we browse the Android emulator / device and create a script without having to manually write any code. We can then repeat the tests over and over to load in data or check for defects. The
scripts created can be edited manually and require little technical knowledge to modify. For this reason record / playback software is excellent for test teams composed of non-technical people who understand a software specification but do not know how to
develop software. Many test teams enjoy using Selenium IDE for this job on a website but what about testing Android applications?

Several such tools exist for Android. One of these is MonkeyTalk SDK (free & open source), there is also BotBot (free & open source) and bitbar TestDroid (proprietary). This guide focuses exclusively on MonkeyTalk.
Getting MonkeyTalk

To use MonkeyTalk you need to set up an account with them. This is pretty straight-forward. Afterwards login and navigate to the download page and get MonkeyTalk IDE:

Download MonkeyTalk

Unzip MonkeyTalk and place it at the root of the C: drive in a folder called "monkeytalk".

Take the MonkeyTalkIDE folder and place it in c:\program files , unless you are running the x86 version on an x64 system, in which case place it in c:\Program Files (x86). 
Aspect J

You will need to install AspectJ to Eclipse. Go to Help > "Install new Software" > In Work with:

Several urls are needed to get the packages you need:

"AJDT Development tools" from: http://download.eclipse.org/tools/ajdt/37/update

(You may also need:

"Apache Maven" from: http://q4e.googlecode.com/svn/trunk/updatesite-iam/  ) 
Setting up a MonkeyTalk Project and Running a Test

Import a suitable program to test in Eclipse, anything simple with a couple of buttons and input boxes will do.
Convert to Aspect J
Right click your project in Eclipse > Configure > "Convert to AspectJ"
Nothing wil appear happen except some visible folder changes.
Create a libs folder in the Android project if none exists.
Navigate to the MonkeyTalk agent for Android, located at:
C:\monkeytalk\agents\android

Copy the android agent into the libs folder from c:\monkeytalk\agents\android
Right click on MonkeyTalk-agent.jar > AspectJ Tools > Add to Aspectpath > You will see some folder changes happen.
Update your AndroidManifest.xml to include the following two permissions:
    android.permission.INTERNET
    android.permission.GET_TASKS

To do this, open the manifest file and add these lines under the root element <manifest> :

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_TASKS" />

Update the project properties (right-click on the project > Properties > Java Build Path), select the Order and Export tab, and check the checkbox next to the AspectJ Runtime Library to export it.

Run the project on a suitable emulator (i.e. same api version). 
Create the MonkeyTalk Project in IDE

Open the MonkeyTalk IDE where scripts will be recorded / played. You may want to create a shortcut to this application.

Create a new MonkeyTalk project by giving it a name and choosing the workspace where all of these will go.

Right click the new project in the MT IDE and select new Script. Give it a filename and click Finish. 
Connecting the MonkeyTalk IDE to the Emulator

Open the MonkeyTalk IDE > Click the test > Click the Android drop down next to the play button > Select "Android Emulator / Tethered Device" > The first time through will ask you to enter the location of the Android SDK > after you exit this screen, click on
the Android icon again and you will get this message in the console if successful:

"Connection set to Android Emulator or Tethered Device"

If not, ensure that the emulator is running and that the app is visible that you want to test. 
Recording through the MonkeyTalk IDE

Load the emulator you want to use with MT installed as in previous steps. Load the application you want to test on the emulator.

Connect as in previous steps.

Click record

Go to the running emulator > Click the steps you need to record in the emulator (similar to Selenium IDE) > Click stop when finished > Click play to play back the test and watch it performing the steps you ran.

That's it!

轉載自:http://testigniter.blogspot.com/2012/06/selenium-for-android-monkeytalk.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.