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
- Package com. Demo;
- Import Io.appium.java_client. Appiumdriver;
- 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.CapabilityType;
- Import org.openqa.selenium.remote.DesiredCapabilities;
- Import Java.io.File;
- Import Java.net.URL;
- Import java.util.List;
- Public class Appdemo {
- 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 (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 = New Appiumdriver (new URL ("Http://127.0.0.1:4723/wd/hub"), capabilities);
- }
- @After
- public void TearDown () throws Exception {
- Driver.quit ();
- }
- @Test
- public void Addcontact () {
- 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 (2). SendKeys ("[email protected]");
- Driver.swipe (+, 2);
- Driver.findelementbyname ("Save"). Click ();
- }
- }
(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