Appium 大家帮个忙,麻烦看下,用 mvn Test 运行测试程序时,启动不了被测试 app,但是能够运行测试用例。

YYGiel · 2014年05月09日 · 最后由 YYGiel 回复于 2014年05月12日 · 2370 次阅读

用 mvn Test 运行测试程序时,启动不了被测试 app,但是能够运行测试用例。用 testng Test 能够运行,这是为什么啊

共收到 10 条回复 时间 点赞

setUp() 里面设置的 Capability 是否正确?把 setUp() 里面的代码贴上来

#1 楼 @kevin_xu_v

public void setUp() throws Exception {  

        DesiredCapabilities capabilities = new DesiredCapabilities();  
        capabilities.setCapability("device","Android");  
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");  
        capabilities.setCapability(CapabilityType.VERSION, "4.4.2");  
        capabilities.setCapability(CapabilityType.PLATFORM, "ANDROID");
        capabilities.setCapability("app-package", "com.duowan.kiwi");  
        capabilities.setCapability("app-activity", "com.duowan.kiwi.simpleactivity.SplashActivity"); 
        driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    }  

我用 testng test 运行能够正常运行的,就 mvn test 不能运行

#2 楼 @zhouxiaoyagirl 如果你用的 appium 是新版本,那么 appium java 的 API 改了,把 app-package 和 app-activity 改为 appPackage 和 appActivity,下次记得把报错信息贴上来。

File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "../../../apps/ContactManager");
File app = new File(appDir, "ContactManager.apk");
前面的 APK path 路径配置下,你代码根本没有配置 APK 路径

#4 楼 @kevin_xu_v 我直接跑的是我手机上已经安装的 app 的,就没有添加路径,我用 testng test 同样可以跑起来的

#4 楼 @kevin_xu_v 刚刚按照你说的,运行了一次还是跑不起来

#4 楼 @kevin_xu_v RemoteTestNG starting
FAILED CONFIGURATION: @BeforeMethod setUp
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.41.0', revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27 11:29:39'
System info: host: 'J8HZS2IMCHOVN3A', ip: '192.168.0.100', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_51'
Driver info: driver.version: Num_1$SwipeableWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:589)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at com.zy.zytest.Num_1$SwipeableWebDriver.(Num_1.java:151)
at com.zy.zytest.Num_1.setUp(Num_1.java:41)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:528)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:205)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:616)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:845)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1169)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.runWorkers(TestRunner.java:1182)
at org.testng.TestRunner.privateRun(TestRunner.java:761)
at org.testng.TestRunner.run(TestRunner.java:612)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:335)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:330)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
at org.testng.SuiteRunner.run(SuiteRunner.java:241)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1169)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1094)
at org.testng.TestNG.run(TestNG.java:1006)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:107)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:199)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:170)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:178)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:322)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:301)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568)
... 32 more
报错这样

Possible causes are invalid address of the remote server or browser start-up failure,跟我上次报的一样,我还没找到解决办法,给 appium 提了个 issue,但是他要求把报错信息发到 google appium 论坛上,我就没弄了。

#8 楼 @kevin_xu_v 那你现在没有使用 Appium 了吗

#9 楼 @zhouxiaoyagirl 没有,目前没搞,appium 还是不是很稳定。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册