一、需要安装或配置的清单:
1.java JDK
2.Xcode
3.eclips (根据个人习惯,选择java开发工具)
4.appium desktop
5.homebrew
6.node
7.npm
8.libimobiledevice
9.carthage
10.ios-deploy
11.xcpretty
12.appium-doctor (可有可无)
二、本次安装的环境
1.macOS:10.13.6
2.appium desktop: 1.6.3
3.Xcode: 9.4.1
4.java JDK: 1.8.0_181
5.java-client: 6.1.0
三、安装步骤,在安装前最好是先链接,国内的防火墙,你懂的。
1.安装java Jdk
a.下载jdk 这里提供一个官网地址Java下载地址
2.安装好java后,安装Xcode,
a.xcode直接在AppStore下载安装即可。
如果安装完Xcode后使用appium-doctor命令还是提示未安装Xcode时,运行xcode-select -p命令看打印出来的路径是不是/Applications/Xcode.app/Contents/Developer 如果不是这个路径,那就执行下面的命令sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
在运行下appium-doctor就会显示Xcode已安装了
3.安装eclipse
a.下载地址 eclipse下载
b.安装eclipse
4.安装appium-desktop
a.下载地址github下载地址, csdn下载地址
b.安装appium desktop,将appium拖入applications,就完成安装了。
5.安装homebrew
a.打开终端,在终端输入
(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
6.安装node
a.在终端输入:brew install node
7.安装npm
a.在终端输入:brew install npm
8.安装libimobiledevice
a.在终端输入:brew install libimobiledevice --HEA
9.安装carthage
a.在终端输入:brew install carthage
10.安装ios-deploy
a.在终端输入:brew install ios-deploy
用npm install -g ios-deploy安装时报错了,后面用brew安装就ok了
11.安装xcpretty
a.在终端输入:gem install xcpretty
b.如果提示You don’t have write permissions,在前面加上sudo,然后会提示输入电脑的登陆秘密。
12.安装appium-doctor
a.在终端输入:npm install -g appium-doctor
b.安装成功后,可以使用appium-doctor --ios 检查appium的ios环境有没有安装成功。
13.WebDriverAgent配置
a.WebDriverAgent地址:
/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
b.打开WebDriverAgent.xcodeproj文件
c.按以下配置操作
d.将WebDriverAgent安装到手机上
A.在终端跳转到WebDriverAgent的目录下,WebDriverAgent目录见上面的a步骤有
B.在终端输入
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id=测试机的udid’ test
C.去描述文件信任就可以了。
至此环境已经安装完成了。
四、在eclipse中创建一个maven项目
a.在pom中配置java-client
io.appium
java-client
6.1.0
b.appium初始化
public class AppTest
{
private static AppiumDriver driver;
public static void main(String[] args) throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iphone 6s Plus");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iostest");
capabilities.setCapability("udid", "测试机id");
//capabilities.setCapability("app", "/Users/hem/ShareSDKDemo.ipa");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.3.1");
capabilities.setCapability("bundleId", "com.mob.product.ShareSDK");
capabilities.setCapability("sessionOverride", false);
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.IOS_XCUI_TEST);
driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(180,TimeUnit.SECONDS);
driver.findElementById("微信好友").click();
//System.out.println(driver.findElement(By.xpath("//XCUIElementTypeStaticText[@name=\"微信好友\"] ")).getText()+"------");
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//XCUIElementTypeStaticText[@name="微信好友"] shareMenuIcon
driver.quit();
}
}
来补一下踩的坑。
之前按网上说的要去github下载一个最新的WebDriverAgent,替换掉appium自带的WebDriverAgent。
当我下载好以后,配置好了替换掉appium自带的WebDriverAgent,结果运行不了。报错。下面为报错log
eclipse log
Exception in thread “main” org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Unhandled endpoint: /session/F885DA2F-2CFF-43CE-A609-5F6F8EA22505/wda/screen – http://localhost:8100/ with parameters {
wildcards = (
“session/F885DA2F-2CFF-43CE-A609-5F6F8EA22505/wda/screen”
);
}
Build info: version: ‘3.12.0’, revision: ‘7c6e0b3’, time: ‘2018-05-08T14:04:26.12Z’
System info: host: ‘youuzdeMac-mini.local’, ip: ‘192.168.110.5’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.13.6’, java.version: ‘1.8.0_181’
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities {app: /Users/hem/ShareSDKDemo.ipa, automationName: XCuiTest, browserName: , databaseEnabled: false, deviceName: iostest, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, platform: MAC, platformName: iOS, platformVersion: 10.3.1, sessionOverride: true, takesScreenshot: true, udid: 71b53307f6b547a37d6e2041443…, webStorageEnabled: false}
Session ID: 0c34de1d-e5a2-4e07-8895-300a2652500f
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at io.appium.java_client.HasSessionDetails.getSessionDetails(HasSessionDetails.java:39)
at io.appium.java_client.HasSessionDetails.getSessionDetail(HasSessionDetails.java:56)
at io.appium.java_client.HasSessionDetails.getPlatformName(HasSessionDetails.java:65)
at io.appium.java_client.internal.JsonToMobileElementConverter.(JsonToMobileElementConverter.java:49)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:89)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:94)
at io.appium.java_client.ios.IOSDriver.(IOSDriver.java:95)
at gameAPI.appium.AppTest.main(AppTest.java:34)
找了半天资料没找到解决办法。还去github问了一下,给github提的问题
按他回复的处理后还是不行。
最后实在解决不了啦,心累。。。。。
最后在testhome里面找到了一个哥们遇到了和我一样的问题。
呀!那个链接找不到了。
解决方法就是,使用appium自带的WebDriverAgent。
问题就解决了。。。。
由于对mac系统不是很熟,Xcode也不熟。所以打这个ios的环境有点费劲。
Android相对来说简单的多。后面在补一个mac下搭建appium的android环境。