通过android模拟器在appium中启动apk文件失败

问题描述 投票:0回答:3

我已成功配置android模拟器,并且设备按预期显示。我也成功启动了appium服务器,并通过eclipse编写了以下脚本。

当我执行代码时,在 appium 以及 eclipse o/p 控制台中返回以下异常:

例外:

> Error: ENOENT, no such file or directory 'C:\Users\bharanik\Downloads\adt-bundle-windows-x86-20130219\adt-bundle-windows-x86-20130219\sdk\build-tools'
>     at Object.fs.readdirSync (fs.js:654:18)
>     at exports.getDirectories (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\helpers.js:100:18)
>     at [object Object].ADB.checkSdkBinaryPresent (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:97:25)
>     at [object Object].ADB.checkAdbPresent (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:134:8)
>     at Function.ADB.createADB (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:73:7)
>     at [object Object].androidCommon.initAdb (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:1083:9)
>     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:610:21
>     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:249:17
>     at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:149:13)
>     at async.eachSeries (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:165:9)
>     at _asyncMap (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:13)
>     at Object.mapSeries (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:231:23)
>     at Object.async.series (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:608:19)
>     at [object Object].ChromeAndroid.start (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\chrome.js:85:9)
>     at [object Object].Appium.invoke (C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:285:17)
>     at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:124:14)
>     at [object Object].ChromeAndroid.configure (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\chrome.js:73:3)
>     at [object Object].Appium.configure (C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:250:15)
>     at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:118:10)
>     at [object Object].Appium.start (C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:129:5)
>     at exports.createSession (C:\Program Files (x86)\Appium\node_modules\appium\lib\server\controller.js:188:16)
>     at Layer.handle [as handle_request] (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
> info: Set mode: Proxying straight through to Chromedriver
> info: [debug] Looks like we want chrome on android
> info: [debug] Creating new appium session 872882ff-89aa-4adb-9774-6506a3bd9c80
> info: [debug] Checking whether adb is present
> info: <-- POST /wd/hub/session 500 27.062 ms - 204 
> info: --> POST /wd/hub/session {"desiredCapabilities":{"platformVersion":"4.4","deviceName":"Android Emulator","platformName":"Android","browserName":"Chrome"}}
> error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress
> info: Client User-Agent string: Apache-HttpClient/4.3.2 (java 1.5)
> info: [debug] Error: Requested a new session but one was in progress
>     at [object Object].Appium.start (C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:139:15)
>     at exports.createSession (C:\Program Files (x86)\Appium\node_modules\appium\lib\server\controller.js:188:16)
>     at Layer.handle [as handle_request] (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:110:13)
>     at Route.dispatch (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:91:3)
>     at Layer.handle [as handle_request] (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\index.js:267:22
>     at Function.proto.process_params (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:100:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Requested a new session but one was in progress)","origValue":"Requested a new session but one was in progress"},"sessionId":"872882ff-89aa-4adb-9774-6506a3bd9c80"}
> info: <-- POST /wd/hub/session 500 10.559 ms - 250 
> Killed Node Server.
> Node Server Process Ended

在没有任何修复的情况下,我尝试执行相同的脚本,但这次它返回了一些不同的异常,如下所示:

异常

 error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress
> info: Client User-Agent string: Apache-HttpClient/4.3.2 (java 1.5)
> info: [debug] Error: Requested a new session but one was in progress
>     at [object Object].Appium.start (C:\Program Files (x86)\Appium\node_modules\appium\lib\appium.js:139:15)
>     at exports.createSession (C:\Program Files (x86)\Appium\node_modules\appium\lib\server\controller.js:188:16)
>     at Layer.handle [as handle_request] (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:110:13)
>     at Route.dispatch (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:91:3)
>     at Layer.handle [as handle_request] (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
>     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\index.js:267:22
>     at Function.proto.process_params (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:100:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
>     at next (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Requested a new session but one was in progress)","origValue":"Requested a new session but one was in progress"},"sessionId":"872882ff-89aa-4adb-9774-6506a3bd9c80"}

有人可以帮忙吗?问题是什么?根本原因是什么?如何解决这个问题?

java selenium-webdriver android-emulator appium
3个回答
1
投票

两者说的是同一件事

error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress
> info: Client User-Agent string: Apache-HttpClient/4.3.2 (java 1.5)
> info: [debug] Error: Requested a new session but one was in progress

服务器中有一个现有会话正在运行您的模拟器。重新启动您的服务器并确保在请求驱动程序对象时没有现有会话正在运行


0
投票

首先,您似乎没有在

.apk
中定义
capabilities
文件的路径。 例如

capabilities.setCapability(MobileCapabilityType.APP, "/root/apps/my_app.apk")
capabilities.setCapability(CapabilityType.BROWSER_NAME, "android")

其次,您似乎在

ANDROID_HOME
环境变量中设置了错误的值 - 这应该就是您收到
build-tools
路径错误的原因。


-3
投票

重新启动你的appium服务器,由于一些超时问题appium会话出现错误,因此apk文件无法正确安装 https://natasatech.wordpress.com/2024/12/20/how-to-install-apk-file-emulator-android-using-appium-desktop-appium-inspector/

© www.soinside.com 2019 - 2024. All rights reserved.