Appium appium 有线能连到设备 无限连不到设备。 但通过 adb 命令能连接到设备

王先生 · 2017年02月10日 · 最后由 恒温 回复于 2017年02月12日 · 8531 次阅读

appium 有线能连到设备 无限连不到设备。 但通过 adb 命令能连接到设备,求指点

共收到 30 条回复 时间 点赞

有知道问题麻烦指导下,急

检查一下手机是否开启监听,通过有线连接,执行命令:adb tcpip 端口,然后在通过无线连接看看

说具体一些?

原理上只要 adb devices 能显示的设备,appium 都能连上。你连不上有可能是你的脚本配置问题。

如果用无线连接,udid 要用 adb devices 显示出来的那个类似 ip 地址的信息,和用有线时显示的会不一样。

终端的 adb connect 连接上了,说明环境没有问题。如果脚本里不行的话,那就是脚本的问题。

#2 楼 @lincj01 我有线连接了手机,设置了 adb tcpip ,然后拔掉线,通过 adb connect ip:端口 连接,完全没有问题,adb devices 也显示有设备。 我断掉后,执行脚本,appium 却连不行 手机

#3 楼 @chenhengjie123 我用 adb 命令执行
D:\AppData\Local\Android\sdk>adb connect 192.168.1.7:5555
connected to 192.168.1.7:5555

D:\AppData\Local\Android\sdk>adb devices
List of devices attached
192.168.1.7:5555 device

ip 端口没有问题 ,下面我发下我失败的日志,和别人成功的日志,可能存在问题的地方 ,麻烦帮我看下
失败日志:> info: --> POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"deviceName":"192.168.1.7:5555","app":"D:\ridepro\robot-framework-demoapp-example3\resources\app\BitbarSampleApp.apk","platformName":"Android","automationName":"appium","appPackage":"com.bitbar.testdroid"}}

info: Client User-Agent string: Python-urllib/2.7

info: [debug] No appActivity desired capability or server param. Parsing from apk

成功日志:2017-02-10 05:40:11:114 - [HTTP] --> POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"deviceName":"106.37.252.16:10002","app":"/home/alex/workspace/robot-framework-demoapp-example/resources/app/BitbarSampleApp.apk","platformName":"Android","automationName":"appium","appPackage":"com.bitbar.testdroid"}}

2017-02-10 05:40:11:119 - [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"deviceName":"106.37.252.16:10002","app":"/home/alex/workspace/robot-framework-demoapp-example/resources/app/BitbarSampleApp.apk","platformName":"Android","automationName":"appium","appPackage":"com.bitbar.testdroid"},{},null,null,null]

有没有可能是没有执行 [MJSONWP] Calling AppiumDriver.createSession() with args
失败这是 No appActivity desired capability or server param. Parsing from apk

能收到各位的回复很是开心,谢谢,但还没解决,麻烦大拿能继续指导

#4 楼 @Lihuazhang 脚本我也发下 哈哈 新手 测试脚本
*** Settings ***
Library AppiumLibrary run_on_failure=Capture Screenshot On Failure

*** Variables ***
${SCREENSHOTS} ${EXECDIR}${/}screenshots${/}
${REMOTE_URL} http://localhost:4723/wd/hub
${APP_PACKAGE} com.bitbar.testdroid
${AUTOMATION_NAME} appium
${PLATFORM_NAME_ANDROID} Android
${PLATFORM_VERSION_ANDROID} 6.0.1 # Uncomment this from the 'Open Application' keyword if you want to be spesific
${DEVICE_NAME_ANDROID} 192.168.1.7:5555 # IP address?
#${DEVICE_NAME_ANDROID} 192.168.1.22:5555 # IP address?
#${DEVICE_NAME_ANDROID} 106.37.252.16:10003 # IP address?
${APP_ANDROID} ${CURDIR}${/}app${/}BitbarSampleApp.apk
#${APP_ANDROID} ${PROJECTROOT}${/}application.apk
${PLATFORM_NAME_IOS} ios
${PLATFORM_VERSION_IOS} 9.0.2 # Uncomment this from the 'Open Application' keyword if you want to be spesific
${DEVICE_NAME_IOS} iOS Emulator # IP address?
${APP_IOS} ${CURDIR}${/}app${/}BitbarIOSSample.ipa
${AUTO_ACCEPT_ALERTS} true

*** Keywords ***
Set Up And Open Android Application
Open Application ${REMOTE_URL} platformName=${PLATFORM_NAME_ANDROID} deviceName=${DEVICE_NAME_ANDROID} app=${APP_ANDROID} automationName=${AUTOMATION_NAME} appPackage=${APP_PACKAGE}
... #platformVersion=${PLATFORM_VERSION_ANDROID}
Wait Until Page Contains What is the best way to test your application 5s

Set Up And Open Ios Application
Open Application ${REMOTE_URL} platformName=${PLATFORM_NAME_IOS} deviceName=${DEVICE_NAME_IOS} app=${APP_IOS} automationName=${AUTOMATION_NAME} appPackage=${APP_PACKAGE}
... autoAcceptAlerts=${AUTO_ACCEPT_ALERTS} #platformVersion=${PLATFORM_VERSION_IOS}
Wait Until Page Contains What is the best way to test your application 5s

Capture Screenshot On Failure
Capture Page Screenshot ${SCREENSHOTS}${/}${TEST NAME}.png

No appActivity desired capability or server param. Parsing from apk

这个是表示你的脚本没定义 activity 名称,appium 会自动从 apk 里面解析获取。这只是一个步骤说明,并不是报错。

你能用 markdown 排下版吗,日志像上面那样用代码块来显示?现在好难分清那些诶是你的失败日志,哪些是你的成功日志。。。
不知道怎么排版的话可以看下回帖框右下角的排版说明。

#9 楼 @chenhengjie123
### 论坛我也是刚来,排版实在用的不熟悉,对不住了
### 失败的:
POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"deviceName":"192.168.1.7:5555","app":"D:\ridepro\robot-framework-demoapp-example3\resources\app\BitbarSampleApp.apk","platformName":"Android","automationName":"appium","appPackage":"com.bitbar.testdroid"}}
[debug] No appActivity desired capability or server param. Parsing from apk

### 成功的:
POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"deviceName":"106.37.252.16:10002","app":"/home/alex/workspace/robot-framework-demoapp-example/resources/app/BitbarSampleApp.apk","platformName":"Android","automationName":"appium","appPackage":"com.bitbar.testdroid"}}

[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"deviceName":"106.37.252.16:10002","app":"/home/alex/workspace/robot-framework-demoapp-example/resources/app/BitbarSampleApp.apk","platformName":"Android","automationName":"appium","appPackage":"com.bitbar.testdroid"},{},null,null,null]

### 有没有可能是没有执行 [MJSONWP] Calling AppiumDriver.createSession() with args
### 我再附上所有的日志

info: --> POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"deviceName":"192.168.1.7:5555","app":"D:\ridepro\robot-framework-demoapp-example3\resources\app\BitbarSampleApp.apk","platformName":"Android","automationName":"appium","appPackage":"com.bitbar.testdroid"}}
info: Client User-Agent string: Python-urllib/2.7
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] Using local app from desired caps: D:\ridepro\robot-framework-demoapp-example3\resources\app\BitbarSampleApp.apk
info: [debug] Creating new appium session a1a6edce-53c8-463d-98d5-796bdc213f62
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_31
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\AppData\Local\Android\sdk\platform-tools\adb.exe
info: [debug] Parsing package and activity from app manifest
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from D:\AppData\Local\Android\sdk\build-tools\25.0.1\aapt.exe
info: [debug] Extracting package and launch activity from manifest.
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\build-tools\25.0.1\aapt.exe dump badging D:\ridepro\robot-framework-demoapp-example3\resources\app\BitbarSampleApp.apk
info: [debug] badging package: com.bitbar.testdroid
info: [debug] badging act: com.bitbar.testdroid.BitbarSampleApplicationActivity
info: [debug] Parsed package and activity are: com.bitbar.testdroid/com.bitbar.testdroid.BitbarSampleApplicationActivity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
warn: UiAutomator did not shut down fast enough, calling it gone
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Error: Could not find a connected Android device.
at [object Object].ADB.getDevicesWithRetry (D:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:606:15)
at [object Object].androidCommon.prepareActiveDevice (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:400:12)
at [object Object]. (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:326:26)
at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
at iterate (D:\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
at [object Object].androidCommon.ensureDeviceLocale (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:371:45)
at [object Object].androidCommon.prepareEmulator (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:364:10)
at [object Object]. (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:325:26)
at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
at iterate (D:\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
at [object Object]. (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:344:9)
at FSReqWrap.oncomplete (fs.js:95:15)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not find a connected Android device.)","origValue":"Could not find a connected Android device."},"sessionId":null}
info: <-- POST /wd/hub/session 500 28002.968 ms - 206
error: Failed to start an Appium session, err was: Error: Could not find a connected Android device.

#10 楼 @wyjcwow 。。。你发之前预览下吧,现在排版明显还是有问题。

排版说明里面的空格都是不可忽略的,不要随便就把空格或者换行符干掉,去掉后就不符合语法了。

论坛我也是刚来,排版实在用的不熟悉,对不住了

你还是花 10 分钟学习下排版吧,否则我们看的太累了。 不要给你要请教问题的人添麻烦。

你的日志根本没有说你没有连接上设备啊,是 No appActivity desired capability or server param. Parsing from apk 这个问题。

#11 楼 @chenhengjie123

这次可以吗?我直接拷的日志文件,我再附上截图,,这次好点了哈
失败的:
info: --> POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"deviceName":"192.168.1.7:5555","app":"D:\\ridepro\\robot-framework-demoapp-example3\\resources\\app\\BitbarSampleApp.apk","platformName":"Android","automationName":"appium","appPackage":"com.bitbar.testdroid"}}
info: Client User-Agent string: Python-urllib/2.7
info: [debug] No appActivity desired capability or server param. Parsing from apk.
成功的:
2017-02-10 05:40:11:114 - [HTTP] --> POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"deviceName":"106.37.252.16:10002","app":"/home/alex/workspace/robot-framework-demoapp-example/resources/app/BitbarSampleApp.apk","platformName":"Android","automationName":"appium","appPackage":"com.bitbar.testdroid"}}
2017-02-10 05:40:11:119 - [debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"deviceName":"106.37.252.16:10002","app":"/home/alex/workspace/robot-framework-demoapp-example/resources/app/BitbarSampleApp.apk","platformName":"Android","automationName":"appium","appPackage":"com.bitbar.testdroid"},{},null,null,null]
有没有可能是没有执行 [MJSONWP] Calling AppiumDriver.createSession() with args
我再附上所有的日志
info: --> POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"deviceName":"192.168.1.7:5555","app":"D:\ridepro\robot-framework-demoapp-example3\resources\app\BitbarSampleApp.apk","platformName":"Android","automationName":"appium","appPackage":"com.bitbar.testdroid"}}
info: Client User-Agent string: Python-urllib/2.7
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] Using local app from desired caps: D:\ridepro\robot-framework-demoapp-example3\resources\app\BitbarSampleApp.apk
info: [debug] Creating new appium session a1a6edce-53c8-463d-98d5-796bdc213f62
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_31
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\AppData\Local\Android\sdk\platform-tools\adb.exe
info: [debug] Parsing package and activity from app manifest
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from D:\AppData\Local\Android\sdk\build-tools\25.0.1\aapt.exe
info: [debug] Extracting package and launch activity from manifest.
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\build-tools\25.0.1\aapt.exe dump badging D:\ridepro\robot-framework-demoapp-example3\resources\app\BitbarSampleApp.apk
info: [debug] badging package: com.bitbar.testdroid
info: [debug] badging act: com.bitbar.testdroid.BitbarSampleApplicationActivity
info: [debug] Parsed package and activity are: com.bitbar.testdroid/com.bitbar.testdroid.BitbarSampleApplicationActivity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
warn: UiAutomator did not shut down fast enough, calling it gone
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Error: Could not find a connected Android device.
     at [object Object].ADB.getDevicesWithRetry (D:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:606:15)
     at [object Object].androidCommon.prepareActiveDevice (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:400:12)
     at [object Object].<anonymous> (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:326:26)
     at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
     at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
     at iterate (D:\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
     at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
     at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
     at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
     at [object Object].androidCommon.ensureDeviceLocale (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:371:45)
     at [object Object].androidCommon.prepareEmulator (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:364:10)
     at [object Object].<anonymous> (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:325:26)
     at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
     at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
     at iterate (D:\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
     at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
     at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
     at D:\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
     at [object Object].<anonymous> (D:\Appium\node_modules\appium\lib\devices\android\android-common.js:344:9)
     at FSReqWrap.oncomplete (fs.js:95:15)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not find a connected Android device.)","origValue":"Could not find a connected Android device."},"sessionId":null}
info: <-- POST /wd/hub/session 500 28002.968 ms - 206 
error: Failed to start an Appium session, err was: Error: Could not find a connected Android device.
失败的 1:

失败的 2:

成功的:

给,排版真对不住了 脚本我也重新发下

*** Settings ***
Library AppiumLibrary run_on_failure=Capture Screenshot On Failure

*** Variables ***
${SCREENSHOTS} ${EXECDIR}${/}screenshots${/}
${REMOTE_URL} http://localhost:4723/wd/hub
${APP_PACKAGE} com.bitbar.testdroid
${AUTOMATION_NAME} appium
${PLATFORM_NAME_ANDROID} Android
${PLATFORM_VERSION_ANDROID} 6.0.1 # Uncomment this from the 'Open Application' keyword if you want to be spesific
${DEVICE_NAME_ANDROID} 192.168.1.7:5555 # IP address?
#${DEVICE_NAME_ANDROID} 192.168.1.22:5555 # IP address?
#${DEVICE_NAME_ANDROID} 106.37.252.16:10003 # IP address?
${APP_ANDROID} ${CURDIR}${/}app${/}BitbarSampleApp.apk
#${APP_ANDROID} ${PROJECTROOT}${/}application.apk
${PLATFORM_NAME_IOS} ios
${PLATFORM_VERSION_IOS} 9.0.2 # Uncomment this from the 'Open Application' keyword if you want to be spesific
${DEVICE_NAME_IOS} iOS Emulator # IP address?
${APP_IOS} ${CURDIR}${/}app${/}BitbarIOSSample.ipa
${AUTO_ACCEPT_ALERTS} true

*** Keywords ***
Set Up And Open Android Application
Open Application ${REMOTE_URL} platformName=${PLATFORM_NAME_ANDROID} deviceName=${DEVICE_NAME_ANDROID} app=${APP_ANDROID} automationName=${AUTOMATION_NAME} appPackage=${APP_PACKAGE}
... #platformVersion=${PLATFORM_VERSION_ANDROID}
Wait Until Page Contains What is the best way to test your application 5s

Set Up And Open Ios Application
Open Application ${REMOTE_URL} platformName=${PLATFORM_NAME_IOS} deviceName=${DEVICE_NAME_IOS} app=${APP_IOS} automationName=${AUTOMATION_NAME} appPackage=${APP_PACKAGE}
... autoAcceptAlerts=${AUTO_ACCEPT_ALERTS} #platformVersion=${PLATFORM_VERSION_IOS}
Wait Until Page Contains What is the best way to test your application 5s

Capture Screenshot On Failure
Capture Page Screenshot ${SCREENSHOTS}${/}${TEST NAME}.png

#12 楼 @Lihuazhang
对呀 ,就是这个问题,为啥连不上呢? 我用 adb 连没有问题的呀


D:\AppData\Local\Android\sdk>adb connect 192.168.1.7:5555
connected to 192.168.1.7:5555

D:\AppData\Local\Android\sdk>adb devices
List of devices attached
192.168.1.7:5555        device


D:\AppData\Local\Android\sdk>adb shell
shell@CP8722:/ $ exit

D:\AppData\Local\Android\sdk>adb disconnect 192.168.1.7:5555
disconnected 192.168.1.7:5555

D:\AppData\Local\Android\sdk>adb devices
List of devices attached

#11 楼 @chenhengjie123
#12 楼 @Lihuazhang
现在看着方便了吗? 还有啥问题? 我看了下别人的帖子,排版没太大问题了吧?

D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices

脚本在执行这块的时候断掉了,是不是你的手机在这个时候休眠了?

#17 楼 @Lihuazhang
不能把?我手机一直处在亮屏状态,不会休眠。而且我也试了很多次,都是这样

#17 楼 @Lihuazhang

No appActivity desired capability or server param. Parsing from apk

脚本没定义 activity 名称,appium 会自动从 apk 里面解析获取,会不会是我的 apk 访问不了?

#19 楼 @wyjcwow 看日志 是 D:\AppData\Local\Android\sdk\platform-tools\adb.exe devices 拿不到设备。不是你的 apk 访问不了。

#20 楼 @Lihuazhang 拿不到设备可能是啥原因呢? 毕竟使用 adb 命令没有问题

#21 楼 @wyjcwow 怎么没问题了? 你代码执行的时候就有问题啊。 你别老拿命令行下执行 adb 说事情啊,你代码执行和你命令行又不是一个环境和上下文。

#22 楼 @Lihuazhang 现在就是找不到问题在哪呀

#23 楼 @wyjcwow 在你运行的代码的时候 在 adb.exe devices 的时候 加些日志看看呗。 或者你 usb 连着的时候看看会不会这样。

#24 楼 @Lihuazhang usb 连接不会这样, 我试试加些日志,这边用的是 rf 脚本,我还不太熟悉。我先看看,有啥结果我晚点发上来

#25 楼 @wyjcwow 保险起见确认下,你在跑 appium 脚本前已经手动跑过 adb connect 命令,并确认在你自己外部的命令行用 adb devices 能看到设备吧?

appium 可不会自动去跑 adb connect 命令。

#26 楼 @chenhengjie123 啥意思? appium 可不会自动去跑 adb connect 命令 , 需要我提前连接好?

#27 楼 @wyjcwow 肯定不会啊。。保持链接是你自己要做的事情,不是 appium 维护的。

#28 楼 @Lihuazhang 那就解决了,谢了。还是基础知识不够。谢了

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