Sikuli+eclipse for Android App Automation testing (first time blogging, some languages are not very professional, look Haihan)

Source: Internet
Author: User

What is Sikuli?

Here is an introduction from the official website: Sikuli is a visual technology to automate and test graphical user interfaces (GUI) using images (screenshots). Sikuli includes Sikuli Script, a visual scripting API for Jython, and Sikuli IDE, an integrated development environment F or writing visual scripts with screenshots easily. Sikuli Script automates anything you see on the screens without internal API ' s support. You can programmatically control a Web page, a windows/linux/mac OS X desktop application, or even an iphone or Android AP Plication running in a simulator or via VNC.

Sikuli is a technique used for UI Automation testing. Sikuli includes Sikul scripts, Jython-based APIs, and Sikuli IDE. Sikuli can implement any automation you can see on your monitor UI objects, you can write some code to implement Web pages, Window/linux/mac OS x desktop apps, even iphone and Android Automated testing of the simulator.

The software and jar packages needed to implement Sikuli+eclipse applications on Android:

1.sikulixsetup-1.1.0.jar/sikulixapi.jar (the former can produce the latter by order)

2.eclipse

3. The master of the Little Lola Control machine

4. One Android phone + data cable

5. apk for Android app

The first step, first of all, is how to generate Sikulixapi.jar packages from Sikulixsetup-1.1.0.jar

Sikulixsetup:
Https://launchpad.net/sikuli/+download

    • Import the jar package into the project;
    • Run the jar package in CMD. Java-jar Sikulixsetup-1.1.0.jar, the startup will download Sikulixapi.jar if the appropriate option is selected. Otherwise it will be error: Libs to export not found on above classpath:/sikulixlibs/mac/libs642.
    • Select a second
    • After the launch there will be fun tips;
    • Locate the downloaded Sikulixapi.jar package in the folder and import it into the project.
    • Put the APK into the project's Apps folder and the apps are built-in

Step two, connect your phone to your computer

The third step, open the small Luo bei control machine master, the mobile phone interface can be seen on the computer.

Fourth, write the code in eclipse with the following code:


Import Org.junit.After;
Import Org.junit.Before;
Import Org.junit.Test;
Import org.sikuli.script.FindFailed;
Import Org.sikuli.script.Screen;

public class Sikulitest {
/* @Before
public void SetUp () throws exception{

System.out.println ("App is launched!");


}*/

@Test

public void Addcontact () throws Findfailed, interruptedexception{
Get your Desktop screen content
Screen s = new screen ();
Picture Storage Path
String imgpath= "D:\\eclipse-jee-mars-2-win32-x86_64\\appium_demo\\pics\\";
Minimize eclipse by clicking Minimize
S.click ("D:\\eclipse-jee-mars-2-win32-x86_64\\appium_demo\\pics\\min1.png");
Find the icon in the master of the desktop controls
S.find (imgpath+ "contect.png");
S.click (imgpath+ "contect.png");

Thread.Sleep (1000);

S.click (imgpath+ "addcontact.png");

Thread.Sleep (1000);
Input ContactName to some
S.type (imgpath+ "Contactname.png", "some");
S.click (imgpath+ "contactemail.png");

Thread.Sleep (1000);

S.type (imgpath+ "Contactemail.png", "some@163.com");

Thread.Sleep (1000);

S.click (imgpath+ "save.png");

System.out.println ("App is done!");
}

@After

public void TearDown () throws Exception {

Here you can add a button that closes the program click, which does not write

}

}

Fifth step, right-click, select Run as--->junit Test runs the program

The use of Sikuli+eclipse to the Android app to automate the test is done, very simple, but sikuli for the image of the lower recognition, so the need to click the location must be accurate, some of the writing is not very detailed, after I add.

Sikuli+eclipse for Android App Automation testing (first time blogging, some languages are not very professional, look Haihan)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.