同事在做 Appium 的自动化平台整合,需求是每个 PC/VM 作为一个执行机,外接一个 Android 设备,现在需要的是能在平台端控制 Appium Server 的启动、关闭、状态监控 (查看是否正常运行)。 暂时我的想法是能否通过批处理来实现,但是仍然没有太好的思路。请问下各位谁有这方面经验或者好的想法?
#1 楼 @lihuazhang 多谢,这个地址确实可以查看到 Appium Server 的运行状态,启动 Appium 可以使用命令行直接启动,那么关闭 Appium Server 有什么方法呢?
.....最简单的方式,把一个 appium server 实例看成一个 process,关闭它就好了。如果直接使用 nodejs 来启停,有对应的 stop 或 unbind 方法。如果使用其他语言,就按照操作 process 方式。java 语言可以参考http://testerhome.com/topics/1864
#5 楼 @weamylady node appium.js
#6 楼 @lihuazhang 启动我知道,怎么停捏?
我用 http://testerhome.com/topics/1864 的方法自动启动了 appium 服务器,
但是 device 就是连接不上,人工启动就可以正常运行,
这是为什么呢?
@cosyman 
我是初学 appium
简单的运行一个 demo
 File root = new File(System.getProperty("user.dir"));
           File appDir = new File(root, "apps");
           File app = new File(appDir, "demo.apk");
           DesiredCapabilities capabilities = new DesiredCapabilities();
           capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
           capabilities.setCapability("platformName", "Android");
            capabilities.setCapability("deviceName","48e524e7");  //48e524e7
            capabilities.setCapability("platformVersion", "2.0");
            capabilities.setCapability("app", app.getAbsolutePath());
            capabilities.setCapability("appPackage", "com.example.android.demo");
            capabilities.setCapability("appActivity", ".DemoActivity");
            driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub/status"), capabilities);
运行之后就会出现如下的错误
java.lang.ExceptionInInitializerError
    at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:65)
    at org.openqa.selenium.remote.internal.HttpClientFactory.(HttpClientFactory.java:55)
    at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:98)
    at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:81)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
    at io.appium.java_client.AppiumDriver.(AppiumDriver.java:109)
    at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:39)
    at AndroidContactsTest.AndroidContactsTest.setUp(AndroidContactsTest.java:35)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.RuntimeException: Stub!
    at org.apache.http.conn.ssl.AbstractVerifier.(AbstractVerifier.java:5)
    at org.apache.http.conn.ssl.AllowAllHostnameVerifier.(AllowAllHostnameVerifier.java:5)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.(SSLConnectionSocketFactory.java:123)
    ... 32 more
