Appium Concise Tutorial (6)--launch Appium and Android simulator

Source: Internet
Author: User
Tags appium

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.

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.