Appium (JAVA) Windows 7 system setup and sample run

Source: Internet
Author: User

Appium (JAVA) Windows 7 system setup and sample runCategory: Appium 2014-11-14 17:44 4323 People read Comments (2) favorite reports

1. Build Android Environment

http://blog.csdn.net/jlminghui/article/details/39582895

Note: The system variable "android_home" needs to be set.


2. Install node. js

http://www.nodejs.org/download/

Download the relevant operating system version


installation process, all the way to "Next".


3, Installation Appium

(1): http://appium.io/ downloaded after the decompression to the local PC, the compressed package has a Appium.cmd file path set to the environment variable path.


(2) Go to the command line and enter Appium-doctor



Also can be installed on-line (optional, network bad or choose the above better)

(1) Enter the command line

(2) Input command: NPM install-g appium

Note: Fq download more reliable

(3) Wait for the update to complete

(4) post-installation verification: Appium-doctor


4. Create a virtual machine or use an actual device

Create a 4.4.2 virtual machine

Not familiar with this piece of friends reference: http://blog.csdn.net/jlminghui/article/details/39582895


5. Create Java Project (ECLIPSE)

(1) Import Selenium class Library

Http://selenium-release.storage.googleapis.com/2.44/selenium-java-2.44.0.zip

Http://selenium-release.storage.googleapis.com/2.44/selenium-server-standalone-2.44.0.jar

(Confirm 2014.11.14 Valid, if invalid please visit http://docs.seleniumhq.org/download/to download)


Note: Need to import two, one is the client, one is the server, the service side library does not import will cause the run times wrong.

(2) Import Appium class Library

Https://search.maven.org/remotecontent?filepath=io/appium/java-client/1.2.1/java-client-1.2.1.jar

(Confirm 2014.11.14 Valid, if invalid please visit http://appium.io/downloads.html to download)

Note: here if you choose to download the latest version of more than 2.0, it will cause the compilation new appiumdriver times wrong. Workaround See:

http://blog.csdn.net/zhubaitian/article/details/39717889 




6, run appium display column


(1) Download the sample program

Https://github.com/appium/sample-code/tree/master/sample-code/apps/ContactManager

Download the link above and place the apps in the current project's Apps directory (directory created by yourself)


(2) Download sample program test

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

The Java file is "content changed as follows

[Java]View Plaincopy
  1. Package com. Demo;
  2. Import Io.appium.java_client. Appiumdriver;
  3. Import Org.junit.After;
  4. Import Org.junit.Before;
  5. Import Org.junit.Test;
  6. Import Org.openqa.selenium.By;
  7. Import org.openqa.selenium.WebElement;
  8. Import Org.openqa.selenium.remote.CapabilityType;
  9. Import org.openqa.selenium.remote.DesiredCapabilities;
  10. Import Java.io.File;
  11. Import Java.net.URL;
  12. Import java.util.List;
  13. Public class Appdemo {
  14. private Appiumdriver driver;
  15. @Before
  16. public void SetUp () throws Exception {
  17. //Set up Appium
  18. File Classpathroot = new File (System.getproperty ("User.dir"));
  19. File Appdir = new File (Classpathroot, "apps");
  20. File app = new File (Appdir, "contactmanager.apk");
  21. Desiredcapabilities capabilities = new Desiredcapabilities ();
  22. Capabilities.setcapability (Capabilitytype.browser_name, "");
  23. Capabilities.setcapability ("PlatformName", "Android");
  24. Capabilities.setcapability ("DeviceName","Android Emulator");
  25. Capabilities.setcapability ("platformversion", "4.4");
  26. Capabilities.setcapability ("app", App.getabsolutepath ());
  27. Capabilities.setcapability ("Apppackage", "Com.example.android.contactmanager");
  28. Capabilities.setcapability ("appactivity", ".  Contactmanager ");
  29. Driver = New Appiumdriver (new URL ("Http://127.0.0.1:4723/wd/hub"), capabilities);
  30. }
  31. @After
  32. public void TearDown () throws Exception {
  33. Driver.quit ();
  34. }
  35. @Test
  36. public void Addcontact () {
  37. Webelement el = driver.findelement (By.name ("Add contact");
  38. El.click ();
  39. list<webelement> textfieldslist = Driver.findelementsbyclassname ("Android.widget.EditText");
  40. Textfieldslist.get (0). SendKeys ("Some Name");
  41. Textfieldslist.get (2). SendKeys ("[email protected]");
  42. Driver.swipe (+, 2);
  43. Driver.findelementbyname ("Save"). Click ();
  44. }
  45. }


(3) Start android4.4.2 virtual machine

(4) command line startup after input: Appium


(5) Project right-click > "Run as" > "JUnit Test" (select Eclipse JUnit Launcher)


The above steps confirm can run successfully, but because the author is also just contact Appium, may exist omission, also please help point out, also can use MAVEN and related Eclipse plug-ins will be more convenient, online example many can find themselves.

Appium (JAVA) Windows 7 system setup and sample run

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.