1) Installing the JDK
: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Installation: The JDK installation is simple and can be installed by default.
To configure environment variables:
Open terminal new. bash_profile file: Touch. Bash_profile
Open a. bash_profile file: Vi. bash_profile
Configure Java_home
Export java_home=$ (/usr/libexec/java_home)
Save exit after executing source. bash_profile
2) Install Xcode
:
Installation: the installation is simple and is added directly to the application.
3) Install command line Tools
Install: Open Terminal input Xcode-select–install
Pop-up Tip "... do you want to install the tool now? ", click Install.
Agree to install the agreement and wait for the installation to complete.
4) Install node. js
:https://nodejs.org
Install: Next, press the default installation.
After the installation is complete, check that the node version installation is successful: Enter the terminal, enter Node-v, you can see the version number, indicating success.
5) Install the SDK and Android API
:http://yunpan.cn/cV9RM3vzqySVP access password: 1CC9
Install: Unzip the package directly to the installation directory.
To configure environment variables:
Open a. bash_profile file: Vi. bash_profile
Configure Android_home
Export Android_home= "/USERS/SUN/ADT-BUNDLE-MAC-X86_64-20140702/SDK" (change to the actual path of your SDK)
Save exit after executing source. bash_profile
Install Updates Android API, do the following:
- Open the terminal to the installation directory of your SDK and run the following command
CD Tools
./android
2. In the Popup SDK Manager window, click on the menu bar of Android SDK Manage-preferences to make the following changes
HTTP Proxy Server Input mirrors.neusoft.edu.cn
HTTP Proxy Port Input 80
Also select Force https:sources to be fetched using HTTP ....
Last click Close closes the setting pop-up window
3. Go to the main screen and select the Android API version you want to install, click Install N Package. Such as:
4. Then appear below this dlg, choose "Accept Lisense", will all tick, click Install.
5. Enter the installation phase (may be slightly slower)
6) Networked Installation Appium
Installation:
Enter the terminal and do the following:
sudo chmod–r 777/usr/local
NPM install–g Appium
Wait a few minutes, log output can see the version of Appium and the installation directory
7) Check the environment
Check and start Appium:
Enter terminal, input Appium &
The following prompt appears: Welcome to Appium ... The instructions are ready to install.
Check the dependent environment:
Enter terminal, input Appium-doctor
The following prompt appears: All Checks were successful indicates that the required environment has been successfully installed.
8) Install Ecplise
:http://www.eclipse.org/downloads/
Install: unzip to the installation directory.
Exception Issue: startup prompts to reinstall Java SE 6 Runtime ...
Workaround: Enter the terminal and do the following
sudo chmod 777/library/java/javavirtualmachines/jdk1.7.0_45.jdk/contents/info.plist
Vi/library/java/javavirtualmachines/jdk1.7.0_45.jdk/contents/info.plist
Will
<key>JVMCapabilities</key>
<array>
<string>CommandLine</string>
</array>
Revision changed to
<key>JVMCapabilities</key>
<array>
<string>JNI</string>
<string>BundledApp</string>
<string>WebStart</string>
<string>Applets</string>
<string>CommandLine</string>
</array>
OK save Restart the computer on OK bird
Configuration Workspace : go to the Eclipse installation directory and click Eclipse. The first boot will require that the project store directory be set up. For example: User/sun/workspace
9) Install ADT Plugin
Online installation: (slower, also available as a second offline installation.) )
- Open Eclipse, menu bar Help->install New Software
- Then, in the popup window, click Add on the back of work with
Name:android
location:https://dl-ssl.google.com/android/eclipse/
Click OK.
3. Select the ADT version that appears in the list and follow the prompts to install. Restart eclipse in effect.
Offline Installation:
: Https://dl.google.com/android/ADT-23.0.6.zip
- Open Eclipse, menu bar Help->install New Software
- Then, in the popup window, click Add on the back of work with
- Then click Archive to add the adt-23.0.6.zip you just downloaded
- After OK, write a name, such as Android
- After parsing, select the ADT version that appears in the list and follow the prompts to install it. Restart eclipse in effect.
10) Configure Appium Client,selenium
:http://yunpan.cn/cVGaGYjF9mcgF access password: 2d90
- New Project Appium (example name) in Eclipse step: file-new-Click Java project-enter project name-Click Finish
- Go to the-appium folder under the project storage directory set up above, for example: E:\workspace\appium
Create a new Lib directory and leave the Java-client-2.2.0.jar,selenium-java-2.43.1.jar,selenium-server-standalone-2.41.0.jar three jar packages in the Lib directory.
3. Return to the Eclipse interface and right-Appium refresh until the Lib directory is displayed. Right-click on the Java-client-2.2.0.jar-build path-in the Lib directory to the add to Build Path
Repeat this step for each of the other two jar packages.
11) Configure JUnit or testng (choose the one you like)
Junit Installation: High version of Eclipse comes with no installation required.
TestNG Installation:
- Open Eclipse, menu bar Help->install New Software
- Then, in the popup window, click Add on the back of work with
Name:testng
Location:http://beust.com/eclipse
Click OK.
3. Select the TestNG version that appears in the list and follow the prompts to install. Restart eclipse in effect.
Appium Related API documentation
Appium Client Part method :http://appium.io/slate/cn/master/?java#appium-Client Library
Appium Service keyword: http://appium.io/slate/cn/master/?java#appium-service key word
Appium element Positioning and Interaction: http://appium.io/slate/cn/master/?java# element Positioning and interaction
Selenium official api:https://selenium.googlecode.com/svn/trunk/docs/api/java/index.html?overview-summary.html
13) Finally put a small example Android real machine:
1 packagecom.allinmd.android; 2 3 ImportOrg.junit.After; 4 ImportOrg.junit.Before; 5 ImportOrg.junit.Test; 6 Import org.openqa.selenium.*; 7 ImportOrg.openqa.selenium.remote.CapabilityType; 8 ImportOrg.openqa.selenium.remote.DesiredCapabilities; 9 ImportIO.APPIUM.JAVA_CLIENT.ANDROID.ANDROIDDRIVER;10 ImportJAVA.NET.URL;11 ImportJAVA.UTIL.CONCURRENT.TIMEUNIT;12 public classAndroidbrowsertest {+ PrivateWebdriver driver;15 16@Before17 public void SetUp () throwsException {desiredcapabilities capabilities = new Desiredcapabilities (); Capabilities.setcapability ("Automationname", "selendroid"); Automation engine capabilities.setcapability ("PlatformName", "Android"); Mobile OS capabilities.setcapability ("Platformversion", "4.1.1"); The Android version of the real machine is capabilities.setcapability ("Udid", "94122ad8"); Physical Machine ID capabilities.setcapability (capabilitytype.platform, "Mac"); Using Mac platform Capabilities.setcapability ("Browsername", "Chrome"); Mobile browser to launch driver = new Androiddriver ("Http://127.0.0.1:4723/wd/hub"), capabilities); Driver.manage (). Timeouts () implicitlywait (timeunit.seconds), }28 @After30 public void TearDown () throws Exception { driver.quit (); }33 @Test35 public void Allinlogin () throws Interruptedexce ption {//Login to Driver.get ("http://m.xxx.cn"), PNs driver.findelement (By.xpath ("html/body/section/div[1]/div[2]/a /div "). Click (); Driver.findelement (By.xpath (".//*[@id = ' allinloginpage ']/div[2]/div[1]/a[2] "). Click (), Driver.findelement (by.id ("email")) SendKeys ("[email protected]"), Driver.findelement (By.name (" Password ")). SendKeys (" 111111 "); Driver.findelement (By.xpath (".//*[@id = ' loginbtn '] "). Click (); 42 }
iOS Simulator:
1 packagecom.allinmd.android; 2 3 ImportOrg.junit.After; 4 ImportOrg.junit.Before; 5 ImportOrg.junit.Test; 6 Import org.openqa.selenium.*; 7 ImportOrg.openqa.selenium.remote.CapabilityType; 8 ImportOrg.openqa.selenium.remote.DesiredCapabilities; 9 ImportIo.appium.java_client. APPIUMDRIVER;11 ImportIO.APPIUM.JAVA_CLIENT.IOS.IOSDRIVER;12 ImportJAVA.IO.FILE;14 ImportJAVA.NET.URL;15 public classIosdemo {+ PrivateAppiumdriver driver;18 19@Before20 public void SetUp () throwsException {File Appdir = new file (System.getproperty ("User.dir"); final file app = new file (appdir, "Apps/testapp/build/release-iphonesimulator/testapp.app")), desiredcapabilities capabilities = new desiredcapabilities (), Capabilities.setcapability (" PlatformName "," IOS "); Mobile OS capabilities.setcapability ("Platformversion", "8.0"); To launch the phone OS version of Capabilities.setcapability ("DeviceName", "IPhone Simulator"); Phone type or simulator type, such as mi_2a/android emulator/iphone Simulator27//Capabilities.setcapability ("Udid", "94122ad8"); Physical Machine ID capabilities.setcapability (capabilitytype.platform, "Mac"); Using the Mac platform Capabilities.setcapability ("app", App.getabsolutepath ()); Get app absolute Path driver = new Iosdriver (New URL ("Http://127.0.0.1:4723/wd/hub" ), capabilities); }32 > @After34 public void TearDown () throws Exception {A//Driver.quit (); }37 $ @Test39 public void Allinlogin () throws Interruptedexception {//Login to final webelement text = driver.findelement (By.xpath ("//uiatextfield[1 ] ")); }"
MacOS10.9 Platform Configuration Appium+java Environment