Appium Test Environment Construction practice

Source: Internet
Author: User
Tags appium

First, the Environment preparation

1. JDK environment configuration A) download and install jdkhttp://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html B) Configure environment Variables B.1 New JAVA_HOME System environment variable: C:\Program files\java\jdk1.8.0_25 b.2 Add%java_home%\bin;%java_home%\lib to the PATH environment variable; 2. Node install a) download and install nodehttps://nodejs.org/en/b) use the node-v command on the cmd command line to check that node uses the installation successfully, if the return version number indicates that the installation was successful, If it fails, check the path path to the failure that contains the node installation path. 3. SDK environment configuration a) download ADTB) Configure environment variable B.1 new android_home system environment variable B.2 add%android_home%\platform-tools to the PATH environment variable;  %android_home%\tools; 4. Appium Environment Configuration

A) Download the Appium compressed package and install it using Appium-installer.exe Appium

b) Configuring Appium environment variables

B.1 Configuration Appium environment variable is C:\Program Files (x86) \appium\node_modules\.bin

B.2 Add%appium% to the PATH environment variable;

B.3 test: cmd input appium-doctor, can see all Checks were successful

Second, write the script

1. Download the Selenium dependency package

Selenium-java-2.45.0.zip

Java-client-2.2.0.jar

2. Create a Java project in Eclipse and import the appropriate jar package

Import Java-client-2.2.0.jar and Selenium-java-2.45.0.jar

Import all jar packages under the Libs directory of Selenium-java-2.45.0.zip

3. Create a test class: Onetest.java

4. Get DeviceName

5. Get Platformversion

Get Android version in phone system information, here is 6.0.1

6. Clear Apppackage and appactivity, which use the mobile phone's own calculator app. Android version is not the same, where Apppackage and appactivity are also different.

7. Get the URL

8. Write the Test code:

Import Java.net.URL; Import Io.appium.java_client. Appiumdriver; Import Io.appium.java_client.android.AndroidDriver; Import Org.openqa.selenium.By; Import Org.openqa.selenium.remote.CapabilityType; Import org.openqa.selenium.remote.DesiredCapabilities; public class Onetest {public static void main (string[] args) throws exception{desiredcapabilities capabilities = new Des Iredcapabilities (); Capabilities.setcapability (Capabilitytype.browser_name, ""); Capabilities.setcapability ("Platforname", "Android"); Capabilities.setcapability ("DeviceName", "05157df53de0042b"); Capabilities.setcapability ("Platformversion", "6.0.1"); Capabilities.setcapability ("Apppackage", "Com.sec.android.app.popupcalculator"); Capabilities.setcapability ("Appactivity", ". Calculator "); Appiumdriver Driver = new Androiddriver (New URL ("Http://127.0.0.1:4723/wd/hub"), capabilities); Driver.findelement (By.name ("9")). Click (); Driver.findelement (By.name ("5")). Click (); Driver.findelement (By.name ("+")). Click (); Driver.findelEment (By.name ("6")). Click (); Driver.findelement (by.name ("=")). Click (); Driver.quit ();  } }

  


9. Start RunningClick the Start button 10. Run the test script

Appium Test Environment Construction practice

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.