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,项目加载的东西大约如下:

抄了一段官方的代码:

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 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版本,如图所示:

选择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)

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

  

再次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终于出来了!

时间: 2024-10-13 08:36:21

Appium 走过的坑( Mac+java )--Apple 篇的相关文章

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

Apple的坑走完后,终于打开了界面,想想还是有点小激动的,然后进入了更坑的Android环境搭建. 如果你以为这环境就和Apple这样easy能解决(虽然不少坑 - -),那就大错特错,android环境等于另外一套东西,比Apple难弄多了,机制也很傻... 牢骚话少说,咱们来跨坑,第一个坑随即而来,之前我在说Apple环境时,下载安装完appium工具,Apple环境自动已经完善(前提是你已经安装完xcode).那么android环境应该怎么配置呢? 我就绕过我求寻真理的沼泽了,直接说怎么

Appium 走过的坑( Mac+java )第三期 --如何自定义编译

前面都讲了一些环境搭建,接下来开始说说如何定位: 在之前,我们安卓的测试案例为例,提到了我们用到一个apk来测试,那么,接下来问题就是,我们如果有这样个apk,但是怎么测试呢? 回到之前appium配置界面 在图标出的地方选择你apk的位置 勾选此处,记住,得先stop appium,不然上面2个图所示部分均为灰色,不可操作! 好了,让我们再次打开appium(安卓虚拟机不要关,保持打开状态) 点击appium界面上的??按钮 会弹出一个新界面框(如果报出500,可能是你的安卓虚拟机没有正常开启

Appium for Mac 环境准备篇

1 Appium for Mac 环境准备篇[原文地址:http://www.cnblogs.com/oscarxie/p/3894559.html] 1.1 java guowenxie-macbookair:~ guowenxie$ java -versionjava version "1.8.0_05"Java(TM) SE Runtime Environment (build 1.8.0_05-b13)Java HotSpot(TM) 64-Bit Server VM (bui

运行Appium碰到的坑们

运行Appium的时候,碰到的那些坑 1. java命令会出现error:could not open ...jvm.cfg 出现这种情况大多是因为电脑上之前安装过JDK,卸载重装之后,运行java命令会出现error:could not open ...jvm.cfg的错误. 打开系统环境变量,查看PATH,会看到诸如此类的配置信息:     %SystemRoot%\system32;%SystemRoot%;......%JAVA_HOME%\lib;%JAVA_HOME%\bin 原因:

云游JAVA —— HelloWorld篇

新注册的博客,审批还挺快,下面就来写下入住博客园的第一篇博客. 这次准备整理一些关于java入门的资料,为什么呢,最近家里那位吵着要学java,要我给她上课,"呵呵". 各位走过路过的大神们,有好的指教欢迎欢迎,好啦,话不多说,云游java基础篇——HelloWorld. JAVA是一种面对对象的开发语言,相信大家知道,同类语言其实也很多,比如.net平台的C#等等吧.至于面向对象这个概念呢,这里我就不班门弄斧啦,想深究"面向对象"的初学者,就去首页看看”面向对象的

Python 踩坑之旅进程篇其四一次性踩透 uid euid suid gid egid sgid的坑坑洼洼

目录 1.1 踩坑案例 1.2 填坑解法 1.3 坑位分析 1.4 技术关键字 1.5 坑后思考 下期坑位预告 代码示例支持 平台: Centos 6.3 Python: 2.7.14 代码示例: 菜单 - Python踩坑指南代码示例 1.1 踩坑案例 小明是个服务器管理员, 他从老管理员手里接手了一个非常繁琐的运维工作: 短暂授权root 账号给不同的 team 接口人运行备份任务 该运维任务有几个特点: 任务需且仅需运行在 root 下 root 账号只能短暂授权给各个小组 通过账号管理平

Java总结篇系列:java.lang.Object

从本篇开始,将对Java中各知识点进行一次具体总结,以便对以往的Java知识进行一次回顾,同时在总结的过程中加深对Java的理解. Java作为一个庞大的知识体系,涉及到的知识点繁多,本文将从Java中最基本的类java.lang.Object开始谈起. Object类是Java中其他所有类的祖先,没有Object类Java面向对象无从谈起.作为其他所有类的基类,Object具有哪些属性和行为, 是Java语言设计背后的思维体现. Object类位于java.lang包中,java.lang包包

Java提高篇——Java实现多重继承

阅读目录 一. 接口二.内部类 多重继承指的是一个类可以同时从多于一个的父类那里继承行为和特征,然而我们知道Java为了保证数据安全,它只允许单继承.有些时候我们会认为如果系统中需要使用多重继承往往都是糟糕的设计,这个时候我们往往需要思考的不是怎么使用多重继承,而是您的设计是否存在问题.但有时候我们确实是需要实现多重继承,而且现实生活中也真正地存在这样的情况,比如遗传:我们即继承了父亲的行为和特征也继承了母亲的行为和特征.可幸的是Java是非常和善和理解我们的,它提供了两种方式让我们曲折来实现多

【转】java提高篇(二)-----理解java的三大特性之继承

[转]java提高篇(二)-----理解java的三大特性之继承 原文地址:http://www.cnblogs.com/chenssy/p/3354884.html 在<Think in java>中有这样一句话:复用代码是Java众多引人注目的功能之一.但要想成为极具革命性的语言,仅仅能够复制代码并对加以改变是不够的,它还必须能够做更多的事情.在这句话中最引人注目的是"复用代码",尽可能的复用代码使我们程序员一直在追求的,现在我来介绍一种复用代码的方式,也是java三大