Appium Java Environment setup

Source: Internet
Author: User
Tags install node appium testng

The Appium is an open source mobile automation testing framework that supports both Android and iOS.

Appium executes the test script based on the Webdriver protocol.

Today, such as fried leftovers, Introduction to build Appium Android environment

Need:

    • Appium Windows Edition, current version is 1.4 https://bitbucket.org/appium/appium.app/downloads/
    • Android SDK, download for yourself
    • Selenium Selenium-server-standalone-2.46.0.jar
    • Java-client
    • Node JS Current version:v0.12.4 https://nodejs.org/download/

First, download install Appium for Windows, in the environment variable path add "; C:\Program Files\nodejs; C:\Program Files (x86) \appium\node_modules\.bin; "

Next Install node JS, install the environment variable path add installation path "; C:\Program Files\nodejs "

Verify node JS: input node-v at the command line, output v0.12.4

Then install the ANDROID SDK and add environment variables: android_home

and add ";%android_home%\platform-tools" in Path

Verify Appium: Enter appium-doctor at the command line and prove the environment is successful if the results are as follows

Next you can create a Java project in eclipse

Create a new Apps folder in project to put contactmanager.apk copy in

Note that this article uses testng, not the eclipse's own JUnit, Baidu

Add Appium Example:

 PackageCom.dbyl.core;Importorg.openqa.selenium.By;Importorg.openqa.selenium.WebElement;ImportOrg.openqa.selenium.remote.CapabilityType;Importorg.openqa.selenium.remote.DesiredCapabilities;ImportOrg.testng.annotations.AfterMethod;ImportOrg.testng.annotations.BeforeMethod;Importorg.testng.annotations.Test;ImportIo.appium.java_client.android.AndroidDriver;ImportJava.io.File;ImportJava.net.URL;Importjava.util.List; Public classAppdemo {PrivateAndroiddriver driver; @BeforeMethod (Alwaysrun=true)     Public voidSetUp ()throwsException {//Set up AppiumFile Classpathroot =NewFile (System.getproperty ("User.dir")); File Appdir=NewFile (Classpathroot, "apps"); File app=NewFile (Appdir, "contactmanager.apk"); Desiredcapabilities Capabilities=Newdesiredcapabilities (); Capabilities.setcapability (Capabilitytype.browser_name,""); Capabilities.setcapability ("PlatformName", "Android"); Capabilities.setcapability ("DeviceName", "Android Emulator"); Capabilities.setcapability ("Platformversion", "4.4"); Capabilities.setcapability ("App", App.getabsolutepath ()); Capabilities.setcapability ("Apppackage", "Com.example.android.contactmanager"); Capabilities.setcapability ("Appactivity", ". Contactmanager "); Driver=NewAndroiddriver (NewURL ("Http://127.0.0.1:4723/wd/hub"), capabilities); } @AfterMethod (Alwaysrun=true)     Public voidTearDown ()throwsException {driver.quit (); } @Test (Groups={"Addcontact"})     Public voidaddcontact () {webelement El= Driver.findelement (By.name ("Add Contact"));        El.click (); List<WebElement> textfieldslist = Driver.findelementsbyclassname ("Android.widget.EditText"); Textfieldslist.get (0). SendKeys ("Some Name")); Textfieldslist.get (1). SendKeys ("10086"); Textfieldslist.get (2). SendKeys ("[Email protected]"); Driver.swipe (100, 500, 100, 100, 2); Driver.findelementbyname ("Save"). Click (); }}

If you see an error, that's right, stating that the dependent packages are not imported.

At this point, you need to import the following 2 jar packages (Selenium-standalone and java-client)

If you execute case, start with a local Android emulator first

Then enter at the command line: Appium

Wait for the command line to appear with the following prompt:

Then run as testng test

Done

Related information: CONTACTMANAGER.APK:HTTP://PAN.BAIDU.COM/S/1I3KLNRZ

Java-client 2.2:HTTP://PAN.BAIDU.COM/S/1PJ7OPSV

Selenium standalone 4.6:HTTP://PAN.BAIDU.COM/S/1QWE7SD2

Appium Java Environment setup

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.