Appium Partial API

Source: Internet
Author: User

Transferred from: http://www.aichengxu.com/view/41510

The language used is Java,appium version is 1.3.4,java-client version is java-client-2.1.0, recommended for multi-reference java-client-2.1.0-javadoc.

1. Using Androiddriver, it has inherited the Appiumdriver

        Private androiddriver driver; @Beforepublic void SetUp () throws Exception {desiredcapabilities capabilities = new Desiredc Apabilities (); Capabilities.setcapability ("devicename", "Android Emulator"); Capabilities.setcapability (" Platformversion "," 4.4 "), Capabilities.setcapability (" PlatformName "," Android "); Capabilities.setcapability (" Apppackage "," com.android.settings "); Capabilities.setcapability (" Appactivity ",". Settings ");d river = new Androiddriver (New URL (" http://127.0.0.1:4723/wd/hub "), capabilities);} @Afterpublic void TearDown () throws Exception {Driver.quit ();} 

2. Screenshot and save to Local

                Screenshot and save to local FILE screen = Driver.getscreenshotas (outputtype.file); File Screenfile = new file ("D:\\screen.png"), try {fileutils.copyfile (screen, screenfile),//commons-io-2.0.1.jar


3.push files, pull files

        data = Base64.encodebase64 (Content.getbytes ());d river.pushfile ("Sdcard/test.txt", data); byte[] Resultdate = Driver.pullfile ("Sdcard/test.txt"); System.out.println (New String (Base64.decodebase64 (resultdate))); Print the result as "test"


4.

        Gets the activity of the current interface, which can be used to assert whether to jump to the expected activity        driver.currentactivity ();


5.

        Open the Notification bar interface        driver.opennotifications ();

6.

        Gets the network state status        = Driver.getnetworkconnection (). value;        SYSTEM.OUT.PRINTLN (status);        Set the network status        driver.setnetworkconnection (new networkconnectionsetting (status));        or        driver.setnetworkconnection (new Networkconnectionsetting (False, True, false));

7.

        Launch other apps, cross app        driver.startactivity ("Com.android.camera", ". Cameralauncher ");

8.

        Auto Slide list        driver.scrollto ("text");        or        driver.scrolltoexact ("text");

9.

                Install Appdriver.installapp (appPath);//Determine if the application is installed driver.isappinstalled ("package name");

10.

        Drag the camera icon to the calendar icon location        new Touchaction (Driver). Longpress (Driver.findelementbyname ("Camera"))        . MoveTo ( Driver.findelementbyname ("Calendar")). Release (). perform ();

11.

                

12.

                Send key event driver.sendkeyevent (Androidkeycode.home);

13.

<style= "color: #ff0000;" > </span>                //Locate the element with a true clickable property by Uiautomator and click Driver.findelementbyandroiduiautomator ("New Uiselector (). Clickable (True) "). Click ();//The element of the same property uses the list to store list<webelement> elements = Driver.findelementsbyclassname ("class name"); Elements.get (0). Click (); Click the first element in list//Tap, click on the element location Driver.tap (1, Driver.findelementbyname ("Date and Time"), 0); 

Appium Partial API

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.