After Apple's pit walk, finally opened the interface, think still a little excited, and then into the more pit of the Android environment to build.
If you think this environment and Apple so easy to solve (although a lot of pits-), it is wrong, the Android environment is equal to another set of things, more difficult than Apple, the mechanism is very silly ...
We came to cross the pit, and the first pit came, and I said before when I was talking about the Apple environment, the Apple environment is automatically completed when you download the Appium tool (provided you have installed Xcode). So how should the Android environment be configured?
I will go around the swamp where I seek truth, and say how to match it directly:
To download an SDK online first
Https://developer.android.com/sdk/index.html
Download the tool under this page or download the SDK can be, recommend the download tool, although not (there is a reason ...) This stupid tool does not recognize me with the 1.8 jdk, as if only the default path of 1.6 and 1.7, forget not to study it.
When the installation is complete, configure the environment variables:
Enter/etc/, edit profile (note: You need to edit the file with the sudo command)
Export android_home=/users/"username"/library/android/sdk
If it is only to download the SDK, extract the general seems to put to/USR/LOCAL/SDK, specific to see, where it actually doesn't matter
Save Close (command: wq!)
Source Profile
The safety point is restarted, and then open the terminal to confirm whether it is useful
CD $ANDROID _home
Check whether the SDK is entered in the directory, if so, congratulations, and crossed a hole.
The next step is to open the tool:
CD Tools
./android
will open a new thing:
Plainly, this is similar to the download-driven thing, that can be down, if you feel slow, the next few of their own to the version (I am all down-...) )
When you are done, note the configuration options for this SDK manager, which has a tools directory (upper-left corner):
Click Tools and then click Manager Avds in the drop-down box
Well, here comes a new thing:
Create a new, I choose the version is the Android 4.4.2 version, the option is very simple, not too much attention, memory, such as 300 enough, can open on the line, save well, start it.
After opening
Andro has been up, and so what, open Appium, click Doctor, see if there is any problem, all OK, only owe JUnit, to paragraph official script:
Import Staticorg.junit.assert.*;ImportJava.io.File;ImportJava.net.URL;Importjava.util.List;Importio.appium.java_client. Appiumdriver;ImportIo.appium.java_client.android.AndroidDriver;ImportOrg.junit.After;ImportOrg.junit.Before;Importorg.junit.Test;Importorg.openqa.selenium.By;Importorg.openqa.selenium.WebElement;Importorg.openqa.selenium.remote.DesiredCapabilities; Public classAppiumandroidtest {PrivateAppiumdriver Dr; @Before Public voidSetUp ()throwsException {File classpathroot=NewFile (System.getproperty ("User.dir")); File Appdir=NewFile (Classpathroot, ".. /.. /.. /apps/apidemos/bin "); File app=NewFile (Appdir, "apidemos-debug.apk"); Desiredcapabilities Capabilities=Newdesiredcapabilities (); Capabilities.setcapability ("DeviceName", "Android Emulator"); Capabilities.setcapability ("Platformversion", "4.4"); Capabilities.setcapability ("PlatformName", "Android"); Capabilities.setcapability ("App", App.getabsolutepath ()); Capabilities.setcapability ("Apppackage", "Io.appium.android.apis"); Capabilities.setcapability ("Appactivity", ". Apidemos "); Dr=NewAndroiddriver (NewURL ("Http://127.0.0.1:4723/wd/hub"), capabilities); } @After Public voidTearDown ()throwsException {dr.quit (); } @Test Public voidTest () {webelement El= Dr.findelement (By.name ("Animation")); Assertequals ("Animation", El.gettext ()); El= Dr.findelementbyclassname ("Android.widget.TextView"); Assertequals ("API Demos", El.gettext ()); El= Dr.findelement (By.name ("App"))); El.click (); List<WebElement> els = dr.findelementsbyclassname ("Android.widget.TextView"); Assertequals ("Activity", Els.get (2). GetText ()); }}
Copy to copy, but I also looked at, found a problem, these two lines of code is what mean:
New File (System.getproperty ("User.dir")); New File (Classpathroot, ".. /.. /.. /apps/apidemos/bin "); New File (Appdir, "apidemos-debug.apk");
Understand the next, is to add the local apk, then this file where it, pull the official tutorial, to have the Apps folder, look for it, how to melt into it, put the directory is not right?
According to the code, the Apps directory is written to the user root directory, then all right, let me just a copy of the CP, put to the ~ directory
Well, since then, we can run the code, remember to appium,android the virtual machine, all open,
"PlatformName", "Android"- --here is the name of your virtual machine.
Congratulations, finally all run up, then, the pit came again, how to get the elements, how can I write a set of their own automated script to come out, please stay appium through the pit (Mac+java) Phase III-How to customize the compilation
Appium through the Pit (Mac+java)--android Chapter