- Mac OS X 10.7 或者更高,推荐最新系统
- XCode >= 4.6.3,推荐最新系统
- Apple Developer Tools (iPhone simulator SDK, command line tools)
![手把手教你搭建MAC appium UI自动化环境 - 燕岭峰寒 - 我的博客](http://img1.ph.126.net/NcPEuJCv_YCKGKMoVIvq4w==/6631238190003071122.jpg)
$ brew -v
Homebrew 0.9.5 (git revision cd4952; last commit 2015-11-12)
如果输入上述命令后,如果没有出现版本信息,说明机器上未安装brew或node。$ node -v
v5.0.0
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install node
git clone git://github.com/ry/node.gitcd node./configuremakesudo make install
npm install -g appium
$ sudo npm uninstall appium -g //卸载appiumunbuild appium@1.3.4$ sudo chmod -R 777 /usr/local //给予非root用户权限$ npm install -g appium //重新安装
git clone git@github.com:appium/python-client.gitcd python-clientpython setup.py install
![MAC下搭建appium UI自动化环境详细步骤 - 燕岭峰寒 - 我的博客](http://img1.ph.126.net/60fIzFVk9vg8mv_YKSw32A==/6631240389026341219.jpg)
$ appiuminfo : Welcome to Appium v1 . 4.13 ( REV c75d8adcb66a75818a542fe1891a34260c21f76a )info : Appium REST http interface listener started on 0.0 . 0.0 : 4723info : Console LogLevel : debug
$ appium - U xxxxxxxxxxxxxxxxxxx -- app xxxxxxxxxxxxinfo : Welcome to Appium v1 . 4.13 ( REV c75d8adcb66a75818a542fe1891a34260c21f76a )info : Appium REST http interface listener started on 0.0 . 0.0 : 4723info : [ debug ] Non - default server args : { "app" : "com.netease.erciyuan" , "udid" : "49455326c3b73198d3091b11227d8a333ed9ce31" }info : Console LogLevel : debug
![MAC下搭建appium UI自动化环境详细步骤 - 燕岭峰寒 - 我的博客](http://img1.ph.126.net/oFoHrvZo1h_dJlaJetvtDA==/6631212901235643466.jpg)
![MAC下搭建appium UI自动化环境详细步骤 - 燕岭峰寒 - 我的博客](http://img0.ph.126.net/waa_UwPvuPEHBfwQhI8H8Q==/6631233791956572525.jpg)
![MAC下搭建appium UI自动化环境详细步骤 - 燕岭峰寒 - 我的博客](http://img2.ph.126.net/vNFs5T-m7dWHC7UcTCEdzA==/6631297563630985841.jpg)
git clone https://github.com/appium/sample-code
cd sample-code/sample-code/apps/TestAppxcodebuild -sdk iphonesimulator
![MAC下搭建appium UI自动化环境详细步骤 - 燕岭峰寒 - 我的博客](http://img2.ph.126.net/xb-Fr-7DJhr-d0RWqRCV0w==/6631360235793766160.jpg)
![MAC下搭建appium UI自动化环境详细步骤 - 燕岭峰寒 - 我的博客](http://img2.ph.126.net/2W5Ei-6WO-vyXY9FGn_xhw==/6631274473886798570.jpg)
![MAC下搭建appium UI自动化环境详细步骤 - 燕岭峰寒 - 我的博客](http://img0.ph.126.net/-dRI1mqyzudnYd4u9ntnSw==/6631287668026337223.jpg)
![MAC下搭建appium UI自动化环境详细步骤 - 燕岭峰寒 - 我的博客](http://img0.ph.126.net/wCwd9ewlOuaivXZG3gH7ew==/6631228294398435501.jpg)
Help -> install new software -> 输入 http://beust.com/eclipse/
资源分享链接:http://pan.baidu.com/s/1bnsb3aB
(1)解压eclipse-testng离线包.zip
(2)将【eclipse-testng离线包/feature】中的文件夹org.testng.eclipse_6.8.6.20130607_0745复制到【MyEclipse安装目录/features】目录下
(3)将【eclipse-testng离线包/org.testng.eclipse_6.8.6.20130607_0745】文件夹复制到【MyEclipse安装目录/plugins】目录下
(4)重启MyEclipse,Windows - show view - TestNG
![MAC下搭建appium UI自动化环境详细步骤 - 燕岭峰寒 - 我的博客](http://img1.ph.126.net/hEafVIwvuxQ7btOV4UeVqw==/6631424007468176701.jpg)
package com.test.firstest;
import java.io.File;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;
import junit.*;
import junit.framework.TestCase;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class FirstTestCases {
public WebDriver wd = null;
@BeforeMethod
public void setUp() throws Exception {
// set up appium
File appDir = new File("/Users/netease/gacha/ios_automation/sample-code/sample-code/sample-code/apps/TestApp/build/release-iphonesimulator");
File app = new File(appDir, "TestApp.app");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "iPhone 5s");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "8.4");
capabilities.setCapability("bundleid", "xxxx");//run on real device
capabilities.setCapability("app", app.getAbsolutePath());
wd = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);
wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
System.out.println("App launched");
}
@AfterMethod
public void tearDown() throws Exception {
wd.quit();
}
@Test
public void testCases() throws InterruptedException {
String myname = "Smriti";
wd.findElement(By.name("Add")).click();
wd.findElement(By.xpath("//textfield[1]")).sendKeys(myname);
wd.findElement(By.name("Save")).click();
Thread.sleep(5000);
// write all your tests here
wd.close();
}
}