请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

正在回答 回答被采纳积分+3

4回答

城下秋草 2018-10-14 22:47:50

类型错了,声明的对象类型和初始化的类型不匹配

AppiumDriver和AndroidDriver是两个对象

0 回复 有任何疑惑可以回复我~
提问者 湛歌 2018-10-14 17:34:20
Exception in thread "main" org.openqa.selenium.WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'VincentdeMacBook-Pro.local', ip: 'fe80:0:0:0:10b5:6690:b81:6ae2%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14', java.version: '1.8.0_181'
Driver info: driver.version: AndroidDriver
	at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:195)
	at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:209)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
	at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
	at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
	at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:84)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:94)
	at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:93)
	at com.Dinner.Test.DinnerTest.main(DinnerTest.java:27)
Caused by: java.lang.reflect.InvocationTargetException
	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:498)
	at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:185)
	... 13 more
Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.mwee.android.pos.dinner' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command '/Users/vincent/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am start -W -n com.mwee.android.pos.dinner/com.mwee.android.pos.business.sync.view.ActiveBizCenterActivity -S' exited with code 1'; Stderr: 'java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.mwee.android.pos.dinner/com.mwee.android.pos.business.sync.view.ActiveBizCenterActivity } from null (pid=13379, uid=2000) not exported from uid 10063
	at android.os.Parcel.readException(Parcel.java:1684)
	at android.os.Parcel.readException(Parcel.java:1637)
	at android.app.ActivityManagerProxy.startActivityAndWait(ActivityManagerNative.java:3208)
	at com.android.commands.am.Am.runStart(Am.java:630)
	at com.android.commands.am.Am.onRun(Am.java:388)
	at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
	at com.android.commands.am.Am.main(Am.java:121)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:262)'; Code: '1'
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'VincentdeMacBook-Pro.local', ip: 'fe80:0:0:0:10b5:6690:b81:6ae2%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14', java.version: '1.8.0_181'
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.mwee.android.pos.dinner' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command '/Users/vincent/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am start -W -n com.mwee.android.pos.dinner/com.mwee.android.pos.business.sync.view.ActiveBizCenterActivity -S' exited with code 1'; Stderr: 'java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.mwee.android.pos.dinner/com.mwee.android.pos.business.sync.view.ActiveBizCenterActivity } from null (pid=13379, uid=2000) not exported from uid 10063
	at android.os.Parcel.readException(Parcel.java:1684)
	at android.os.Parcel.readException(Parcel.java:1637)
	at android.app.ActivityManagerProxy.startActivityAndWait(ActivityManagerNative.java:3208)
	at com.android.commands.am.Am.runStart(Am.java:630)
	at com.android.commands.am.Am.onRun(Am.java:388)
	at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
	at com.android.commands.am.Am.main(Am.java:121)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:262)'; Code: '1'
    at getResponseForW3CError (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:826:9)
    at asyncHandler$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:404:37)
    at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at <anonymous>
	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.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
	at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
	at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
	at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
	at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
	... 18 more
	

我百度了一下可能是包引入的问题,我修改了导入的三个包又发生了上述的报错。出错的地点如下:

AppiumDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);

谢谢老师帮我看一下为啥会有这个问题。。视频中的例子我实现了一次,但是重启了一下电脑就再也运行不起来了。。

0 回复 有任何疑惑可以回复我~
提问者 湛歌 2018-10-14 17:31:02
AppiumDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);

这就是我第26行的信息。

0 回复 有任何疑惑可以回复我~
城下秋草 2018-10-13 20:21:12

main函数26行你写的啥?应该代码写得有问题

提问要学会提供完整信息。

0 回复 有任何疑惑可以回复我~
  • 提问者 湛歌 #1
    我的错,有个地方写错了=。=麻烦老师了
    回复 有任何疑惑可以回复我~ 2018-10-14 20:54:35
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信