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