Appium appiumDriverLocalService.start () 报错

Ender · 2017年07月25日 · 最后由 Suny 回复于 2017年08月24日 · 2184 次阅读

AppiumDriverLocalService service = AppiumDriverLocalService.buildService(
new AppiumServiceBuilder()
.withArgument(GeneralServerFlag.LOG_LEVEL, "info")
.withIPAddress("127.0.0.1").usingPort(4723));
@BeforeClass
public void setup() {
service.start();
}

———————————————————————
org.testng.TestNGException:
Cannot instantiate class NotLogin
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:31)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:410)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:323)
at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:126)
at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:191)
at org.testng.TestClass.getInstances(TestClass.java:99)
at org.testng.TestClass.initTestClassesAndInstances(TestClass.java:85)
at org.testng.TestClass.init(TestClass.java:77)
at org.testng.TestClass.(TestClass.java:42)
at org.testng.TestRunner.initMethods(TestRunner.java:423)
at org.testng.TestRunner.init(TestRunner.java:250)
at org.testng.TestRunner.init(TestRunner.java:220)
at org.testng.TestRunner.(TestRunner.java:161)
at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:578)
at org.testng.SuiteRunner.init(SuiteRunner.java:185)
at org.testng.SuiteRunner.(SuiteRunner.java:131)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1383)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1363)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1217)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:127)
Caused by: java.lang.reflect.InvocationTargetException
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.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:23)
... 22 more
Caused by: io.appium.java_client.service.local.InvalidNodeJSInstance: Node.js is not installed!
at io.appium.java_client.service.local.AppiumServiceBuilder.findDefaultExecutable(AppiumServiceBuilder.java:196)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:330)
at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:76)
at NotLogin.(NotLogin.java:24)
... 27 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/exec/DaemonExecutor
at org.openqa.selenium.os.UnixProcess.(UnixProcess.java:53)
at org.openqa.selenium.os.CommandLine.(CommandLine.java:38)
at io.appium.java_client.service.local.AppiumServiceBuilder.findDefaultExecutable(AppiumServiceBuilder.java:192)
... 30 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.exec.DaemonExecutor
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 33 more
——————————————————————————————————————

以上错误在 maven 中添加:

org.seleniumhq.selenium
selenium-java
3.4.0

共收到 2 条回复 时间 点赞

已解决,方便以后有人出现问题查询

Ender 回复

能帮忙看看我这个问题么?通过这种方式启动 appium service 总提示这个错误。

Exception in thread "main" io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: /usr/local/Cellar/node/8.1.4/bin/node Arguments: [/usr/local/lib/node_modules/appium/build/lib/main.js, --port, 4723, --address, 0.0.0.0]

at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:149)
at MyTest.Test.main(Test.java:21)
Caused by: java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.(Ljava/util/concurrent/ExecutorService;) V from class org.openqa.selenium.net.UrlChecker
at org.openqa.selenium.net.UrlChecker.(UrlChecker.java:67)
at io.appium.java_client.service.local.AppiumDriverLocalService.ping(AppiumDriverLocalService.java:113)
at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:136)
... 1 more

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