In general, we start Appium from the command line.
Windows, DOS command window input
Appium
If this command is an error, please reload Appium
Install -G appium
If an installation error occurs, replace the NPM source yourself.
Npm-g--registry http://registry.cnpmjs.org Install Appium
Then please open the Android emulator, if not please create a new virtual device
The following code is an example of starting the Android native Calculator program
Ruby article
' Appium_lib ' caps = {caps: 'Android'. Calculator'com.android.calculator2' }, = Appium::D river.new (Caps)
Discussion: You can see the Appium in Ruby Lib: The:D River is actually a subclass of the native Webdriver class, and of course, because Ruby syntax is flexible, you can also use monkey patch to achieve similar functionality.
Python article
from appium import webdriver
Desired_caps ={}desired_caps['PlatformName'] ='Android'desired_caps['platformversion'] ='4.2'desired_caps['devicename'] ='Android Emulator'desired_caps['Apppackage'] =' Com.android.calculator2 'desired_caps['appactivity'] ='. Calculator 'Driver= Webdriver. Remote ('Http://localhost:4723/wd/hub', Desired_caps)
Discussion: Webdriver. Remote is actually a subclass of the native Webdriver, and the first parameter of the remote () constructor needs to display the port that the specified Appium server listens on
Java Chapter
When creating a new Java project, be aware of importing selenium-webdriver and Appium client jar packages
Importio.appium.java_client. Appiumdriver;Importorg.openqa.selenium.By;Importorg.openqa.selenium.WebElement;ImportOrg.openqa.selenium.remote.CapabilityType;ImportOrg.openqa.selenium.remote.desiredcapabilities;desiredcapabilities Capabilities=Newdesiredcapabilities (); Capabilities.setcapability (Capabilitytype.browser_name,"");//This sentence is not necessary capabilities.setcapability ("DeviceName", "Android Emulator"); Capabilities.setcapability ("Platformversion", "4.4"); Capabilities.setcapability ("PlatformName", "Android"); Capabilities.setcapability ("Apppackage", "Com.android.calculator2"); Capabilities.setcapability ("Appactivity", ". Calculator "); Appiumdriver Driver=NewAppiumdriver (NewURL ("Http://127.0.0.1:4723/wd/hub"), capabilities);
Discussion: Appiumdrvier is a subclass of native Webdriver.
Here we can see that when you create a new driver, you have to specify a Desiredcapabilities object, and the object is sacred, and we'll explain it in the next section.