Appium 走过的坑( Mac+java )--Apple 篇

最近随着手机测试盛行,经朋友推荐,selenium的新家庭成员Appium算比较好用的一款自动化手机测试工具。本想,selenium出的东西都是好东西,IDE-->RC-->WebDriver-->PhantomJS,个个都是好东西,当然其中有些不适selenium做的,算半个推荐,但真心不错,那这个Appium也不会差吧。。。抱着试试的心态,开始了踏坑之旅。下面就让我描述下我走过的坑:

 

首先先说下环境:

Mac pro (OS X 10.10.3)

Java (1.6 , 后续会介绍怎样让mac升成1.8)

eclipse ( Luna Service Release 2 (4.4.2) )

Appium ( java-client-2.2.0.jar )

Appium Desktop app ( appium.dmg  1.4.1 可能有些朋友找不到,其实就是排序最高的那个,没有写版本号,但装完会发现是1.4.1)

Selenium ( selenium-java-2.46.0.jar , selenium-server-standalone-2.46.0.jar )

xcode (不列版本了,装最新的就行)

 

Appium Desktop app可以替换之前很多网上找到的复杂安装流程,既然有,就要用,不然浪费了人家的一片苦心不是,安装完后,点击doctor按钮,会发现,修复一下后,只有Apple方面是OK的,下面先讲Apple吧,之后再来说Android。

 

接下来就让我们在eclipse创建一个新项目开始吧:

我建了一个叫做TestAppium,项目加载的东西大约如下:

Appium 走过的坑( Mac+java )--Apple 篇_第1张图片

抄了一段官方的代码:

import org.junit.After;
import org.junit.Before;

import java.net.URL;

import io.appium.java_client.ios.IOSDriver;

import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class AppiumTest {
	WebDriver wd;

	@Before
	public void setUp() throws Exception {
		DesiredCapabilities capabilities = new DesiredCapabilities();
		capabilities.setCapability("deviceName", "iPhone 6");
		capabilities.setCapability("platformVersion", "6");
		capabilities.setCapability("platformName", "iOS");
		capabilities.setCapability("browserName", "safari");

		wd = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"),
				capabilities);

	}

	@After
	public void tearDown() throws Exception {
		wd.quit();
	}

	@Test
	public void test() throws Exception {
		wd.get("http://www.google.com");
		Thread.sleep(1000);
	}

}

 开启Appium DeskTop app,当然也做了点配置( 红圈是重点,和代码对应 ):

Appium 走过的坑( Mac+java )--Apple 篇_第2张图片

按下Appium DeskTop app的launch按钮,然后运行Junit代码,很好,第一个坑如约而至:

java.lang.UnsupportedClassVersionError: io/appium/java_client/ios/IOSDriver : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at AppiumTest.setUp(AppiumTest.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

java.lang.NullPointerException
	at AppiumTest.tearDown(AppiumTest.java:30)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

  “java.lang.UnsupportedClassVersionError: io/appium/java_client/ios/IOSDriver : Unsupported major.minor version 51.0”

这是个什么东西,从来没有版本是51.0的啊,随之搜索答案,发现需要java版本1.7以上,看起来这个坑很好填,那我们动手吧:

Mac是这样,系统自带java,但是版本吧,不忍直视,1.6,目前是没法升级,那怎么办?自己动手,丰衣足食呗。

首先去java官网安装Mac版本最新的java安装包,随后,下一步,下一步,安装完。

打开终端,输入 java -version,好样的,还是1.6,第二个坑也来了,Mac你是闹怎样?

平定下情绪,咱们还是解决问题吧,既然装了,这个java去哪里了呢?

打开系统偏好设置,发现最下面一排会有一个java的图标,那就打开看看吧。

一个java的控制面板,真的是简洁大方有档次,干净到不能再干净。好好翻翻,发现了这个:

复制路径地址:/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java

原来你在这里啊,那我直接配置你到环境变量吧。

这里有个小插曲,我首先想把他引入eclipse,但是JavaAppletPlugin.plugin不是一个文件夹,这下好,那就索性copy出来,省的以后出问题

打开终端 :

cp -rf /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home ~

然后,在/etc/下,编辑一个叫profile的文件,在最下端加入:

export JAVA_HOME=~/Home

保存退出,这里有个问题,如果不是用sudo是不能保存的,那怎么办:

sudo vim /etc/profile

编辑完后,按esc后:

输入wq!

再次打开确认下,的确能写入了。

接下来,source /profile

好了,环境变量配好了,可能没生效,重启或者用户注销再登入一下。

再来一次,java -version

终于1.8了,然后eclipse也配置下,引入1.8。回到项目,这里修改java版本,如图所示:

Appium 走过的坑( Mac+java )--Apple 篇_第3张图片

选择1.7,够用就行来,别到时候又来问题。

绕了一个大圈,能运行了吧,咱们来试试( 打开appium launch, run junit ):

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: ‘2.46.0‘, revision: ‘87c69e2‘, time: ‘2015-06-04 16:17:10‘
System info: host: ‘caochengdeMacBook-Pro.local‘, ip: ‘192.168.102.153‘, os.name: ‘Mac OS X‘, os.arch: ‘x86_64‘, os.version: ‘10.10.3‘, java.version: ‘1.8.0_45‘
Driver info: driver.version: IOSDriver
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:109)
	at io.appium.java_client.ios.IOSDriver.<init>(IOSDriver.java:23)
	at AppiumTest.setUp(AppiumTest.java:24)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:4723 [/127.0.0.1] failed: Connection refused
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
	at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
	at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:143)
	at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:89)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:134)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:578)
	... 31 more
Caused by: java.net.ConnectException: Connection refused
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
	... 44 more

java.lang.NullPointerException
	at AppiumTest.tearDown(AppiumTest.java:30)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

这个妖孽是什么东西,配置里查找一番,发现之前配置的时候多填了一项,关了就行:

  Appium 走过的坑( Mac+java )--Apple 篇_第4张图片

再次launch,坑又来了:

org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Could not find a device to launch. You requested ‘iPhone 6 (6 Simulator)‘, but the available devices were: ["iPad 2 (8.3 Simulator) [91098947-0E95-4BCC-B1CF-5283D1F33A3F]","iPad Air (8.3 Simulator) [59C14602-49D9-40B1-87B3-21A068E9B737]","iPad Retina (8.3 Simulator) [8E8F54E3-084F-42E7-8F3A-530A990BE1A5]","iPhone 4s (8.3 Simulator) [DAD508E7-9967-4408-92B1-3D2FBCB3F7C5]","iPhone 5 (8.3 Simulator) [D507787F-278F-4FDD-B87E-9CF0B8CA4FF2]","iPhone 5s (8.3 Simulator) [2E075526-B6E0-4E63-BDD3-617AB269CB17]","iPhone 6 (8.3 Simulator) [D0F0D816-D747-479F-9E87-74F4DD5E3E39]","iPhone 6 Plus (8.3 Simulator) [B2FBBE5A-5F95-4D83-B284-50A7E4C16AC7]"]) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 467 milliseconds
Build info: version: ‘2.46.0‘, revision: ‘87c69e2‘, time: ‘2015-06-04 16:17:10‘
System info: host: ‘caochengdeMacBook-Pro.local‘, ip: ‘192.168.102.153‘, os.name: ‘Mac OS X‘, os.arch: ‘x86_64‘, os.version: ‘10.10.3‘, java.version: ‘1.8.0_45‘
Driver info: io.appium.java_client.ios.IOSDriver
	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:422)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:109)
	at io.appium.java_client.ios.IOSDriver.<init>(IOSDriver.java:23)
	at AppiumTest.setUp(AppiumTest.java:24)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

java.lang.NullPointerException
	at AppiumTest.tearDown(AppiumTest.java:30)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

  这个坑比较好解决,看我errorlog就懂了,说我填的版本不对,那就改成标准版本:

capabilities.setCapability("platformVersion", "6");
change to
capabilities.setCapability("platformVersion", "8.3");

  再次运行,iPhone终于出来了!

Appium 走过的坑( Mac+java )--Apple 篇_第5张图片

你可能感兴趣的:(java,mac,iPhone,appium,自动化测试)