Android Automated Test Appium

Source: Internet
Author: User
Tags appium

1, install Nodejs test installation is successful: Run cmd, enter command node-v

2, install the Android SDK package, because I use ordinary eclipse as long as the installation of the ADT plug-in eclipse, andand make sure you install theLevel17or more of the versionAPI. SetAndroid_home System Variables for yourAndroid SDKpath, and putToolsand thePlatform-toolstwo directories added to the systemPathpath.

3. Install Maven Plugin

4, install Appium: in cmd use command npm install–g appium

5. start Appium in cmd

6. Running Instance Code

Package Com.saucelabs.appium;import Java.io.file;import java.net.url;import java.util.list;import org.junit.After; Import Org.junit.before;import Org.junit.test;import Org.openqa.selenium.by;import Org.openqa.selenium.capabilities;import Org.openqa.selenium.webdriver;import org.openqa.selenium.WebElement; Import Org.openqa.selenium.interactions.hastouchscreen;import Org.openqa.selenium.interactions.TouchScreen; Import Org.openqa.selenium.remote.capabilitytype;import Org.openqa.selenium.remote.desiredcapabilities;import Org.openqa.selenium.remote.remotetouchscreen;import Org.openqa.selenium.remote.remotewebdriver;public Class  Androidcontactstest {public class Swipeablewebdriver extends Remotewebdriver implements Hastouchscreen {private    Final Remotetouchscreen Touch; Public Swipeablewebdriver (Final URL remoteaddress, final capabilities Desiredcapabilities) {Super (Remoteaddre      SS, Desiredcapabilities);    Touch = new Remotetouchscreen (Getexecutemethod ()); } pUblic touchscreen Gettouch () {return touch;  }} private Webdriver driver;    @Test public void Addcontact () {final webelement el = driver.findelement (By.name ("Add contact");    El.click ();    Final list<webelement> textfieldslist = Driver.findelements (by. TagName ("TextField"));    Textfieldslist.get (0). SendKeys ("Some Name");    Textfieldslist.get (2). SendKeys ("[email protected]");  Driver.findelement (By.name ("Save")). Click (); } @Before public void SetUp () throws Exception {Final file app = new file ("C:/users/administrator/desktop/ap    Pium/appium-master/sample-code/apps/contactmanager/contactmanager.apk ");    Final desiredcapabilities capabilities = new Desiredcapabilities ();    Capabilities.setcapability ("Device", "Android");    Capabilities.setcapability (Capabilitytype.browser_name, "");    Capabilities.setcapability (Capabilitytype.version, "4.2");    Capabilities.setcapability (Capabilitytype.platform, "MAC"); Capabilities.setcapabilitY ("App", App.getabsolutepath ());    Capabilities.setcapability ("App-package", "Com.example.android.contactmanager"); Capabilities.setcapability ("App-activity", ".    Contactmanager ");  Driver = new Swipeablewebdriver (New URL ("Http://127.0.0.1:4723/wd/hub"), capabilities);  } @After public void TearDown () throws Exception {driver.quit (); }}

code from place of address



Android Automated Test Appium

Related Article

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.