Appium Environment Building (Windows edition)

Source: Internet
Author: User
Tags appium

Note: Appium installs to C drive, node. JS installs to C drive

I. Installing node. js

1, to the official website download node.js:https://nodejs.org/en/download/

2, get to the installation file, directly double-click the installation file, according to the program prompts, complete the installation of Nodejs.

3, after the installation is complete, run cmd, enter Node–v, if the installation is successful, will output the following version information:

Second, configure the Android SDK environment

1. SDK environment configuration:http://www.cnblogs.com/puresoul/p/4597211.html

2. Ensure that version API with level 17 or above is installed

3. Set the Android_home system variable to your ANDROID SDK path

F:\Program Files (x86) \ANDROID\ANDROID-SDK

4. Add tools and Platform-tools two directories to the path of the system

    ; F:\Program Files (x86) \android\android-sdk\platform-tools; F:\Program Files (x86) \android\android-sdk\tools

Third, install the mobile phone driver and test the connection to the real machine

After you complete the above steps, to enable the phone to connect to the PC side for the real machine test. You will also need to install the driver for your test phone. Download the appropriate offline driver and install it according to the phone model, then connect the phone to the PC via USB cable. Enter the following command in CMD, if you can see the device, it means that the installation was successful.

iv. installation of Appium

1. Download the installation file:https://bitbucket.org/appium/appium.app/downloads/

2. Directly double-click the Appium-installer.exe file to install, the desktop will generate a appium icon

3. Place the Node_modules Bin directory in the path of the system

C:\Program Files (x86) \appium\node_modules\.bin

4. Check if the environment required for the appium is OK:

Enter cmd command line, enter Appium-doctor, the following prompt appears, all Checks were successful, indicating that the environment is successful.

Second, Appium Getting Started instance (Java)

a , create a case project directly with Eclipse

1. Open Eclipse, "File"--"New"--"Project"

2. Select "Java Project"--"Next"

3, enter the project name Appium_demo, click "Finish"

4, right click on the project New-folder, new two folders: Apps and Libs, directory structure as follows:

two , import the test class library

1, Import Selenum class library: http://docs.seleniumhq.org/download/

1) Selenium-server-standalone-2.44.0.jar

2) Selenium-java-2.44.0.zip

2. Import the Appium class library:

1) Java-client-1.2.1.jar

3, right click on the project blank, select "Build Path"--"Configure Build Path"

three , download test apk

1, download the test file Contactmanager.apk:https://github.com/appium/sample-code/tree/master/sample-code/apps/contactmanager

2. Put the downloaded apk into the project's Apps directory

Four , build package packages and Case Files

  1. Right-click on the src folder, "New"--"package", enter the bundle name: Com.dan.demo, click "Finish"

2, in the package under the new class: Contactstest.java, as follows:  

  : Https://github.com/appium/sample-code/tree/master/sample-code/examples/java/junit/src/test/java/com/saucelabs/appium

Package Com.dan.demo;

Import io.appium.java_client. Appiumdriver;

import io.appium.java_client.android.AndroidDriver;

import io.appium.java_client.android.AndroidElement;

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.WebElement;

import org.openqa.selenium.remote.DesiredCapabilities;

Public class contactstest {

Private Appiumdriver driver;

@Before

Public void setUp () throws Exception {

Set up Appium

File Classpathroot = new file (System. GetProperty("User.dir"));

File Appdir = new file (Classpathroot, "/apps");

File app = new file (Appdir, "contactmanager.apk");

Desiredcapabilities capabilities = New desiredcapabilities ();

Capabilities.setcapability ("DeviceName", "4d1219502472216f");

Capabilities.setcapability ("Platformversion", "4.4");

Capabilities.setcapability ("App", App.getabsolutepath ());

Capabilities.setcapability ("Apppackage", "Com.example.android.contactmanager");

Capabilities.setcapability ("Appactivity", ". Contactmanager ");

Driver = new androiddriver<> (new URL ("Http://127.0.0.1:4723/wd/hub"), capabilities);

System. out. println ("App is launched!");

}

@Test

Public void addcontact () {

Webelement el = Driver.findelement (by. Name("Add contact");

El.click ();

list<androidelement> textfieldslist = Driver.findelementsbyclassname ("Android.widget.EditText");

Textfieldslist.get (0). SendKeys ("Some Name");

Textfieldslist.get (2). SendKeys ("[email protected]");

Driver.swipe (100, 500, 100, 100, 2);

Driver.findelementbyname ("Save"). Click ();

System. out. println ("App is done!");

}

@After

Public void TearDown () throws Exception {

Driver.quit ();

}

}

Five , start the Android emulator (you can also connect to the real machine)

1. cmd input: Android AVD, select Simulator, click "Start". For specific reference:http://www.cnblogs.com/puresoul/p/4597211.html

2, start well, cmd input: adb devices, determine whether the device is connected, such as the successful connection:

Six , start Appium

Method One: cmd input: Appium

Method Two:

1. Double-click the Appium GUI icon directly (for example):

2. Click the Start button in the top right corner to start the log as follows:

Seven , run the test case:

1. In Eclipse, the project right > "Run as" > "JUnit Test" Run as follows:

Viii. results ofEclipse operation:

Nine, appium operation result:

Category: Appium Learning

Appium Environment Building (Windows edition)

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.