在......中找不到“ adb.exe”?

时间:2019-08-21 23:15:23

标签: python-3.x adb appium

如何修复找不到“ adb.exe”?

我认为我的问题是Android世界中最常被问到的问题之一。我全部阅读并尝试过。

  • 我检查并更新了环境变量。
  • 我已卸载并重新安装了ANdroid Studio
  • 我将粘贴的adb复制到了所有可能的文件夹中:     C:\ Users \ Nino \ AppData \ Local \ Android \ Sdk     C:\ Program Files \ Android     C:\ Program Files \ Android \ tools     C:\ Program Files \ Android \ platform-tools

事实上,我整天都在搜索,阅读和测试所有可能的解决方案。

没有任何东西可以解决我的问题。所以我真的需要你的帮助。

我是新手,我想分享自己的经验。这是我的代码:

from appium import webdriver
import unittest

from selenium.webdriver.common.by import By


class Instagram(unittest.TestCase):
    def setUp(self):
        desired_caps = {}
        desired_caps['platformName']='Android'
        desired_caps['platformVersion']='6.0'
        desired_caps['deviceName']='S6S5IN3G'
        desired_caps['noReset']='true'
        desired_caps['appPackage']='com.instagram'
        desired_caps['appActivity']='com.instagram.android.activity.MainTabActivity'

        self.driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
        #self.driver = webdriver.Remote('http://0.0.0.0:4723/wd/hub',desired_caps)

    def tearDown(self):
        self.driver.quit()

    def test_scrap_email(self):
        search_button = self.driver.findElement(By.xpath ("//android.widget.ImageView[@bounds='[126,800][162,836]']"))
        search_button.click()



if __name__ == '__main__':
    suite = unittest.Testloader().loadTestsFromTestCase(Instagram)
    unittest.TextTestRunner(verbosity=1).run(suite)

这是错误:

  

测试从01:00开始...   C:\ Users \ Nino \ PycharmProjects \ Instagram \ venv \ Scripts \ python.exe   “ C:\ Program Files \ JetBrains \ PyCharm社区版   2019.1.3 \ helpers \ pycharm_jb_unittest_runner.py“ --target mybot_instagram.Instagram.test_scrap_email使用以下命令启动单元测试   参数python -m unittest   mybot_instagram.Instagram.test_scrap_通过电子邮件发送   C:\ Users \ Nino \ PycharmProjects \ Instagram

     

错误回溯(最近一次通话最近):文件   “ C:\ Users \ Nino \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ unittest \ case.py”,   第59行,在testPartExecutor中       产生文件“ C:\ Users \ Nino \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ unittest \ case.py”,   624行,运行中       self.setUp()文件“ C:\ Users \ Nino \ PycharmProjects \ Instagram \ mybot_instagram.py”,第17行   在setUp中       self.driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)文件   “ C:\ Users \ Nino \ PycharmProjects \ Instagram \ venv \ lib \ site-packages \ appium \ webdriver \ webdriver.py”,   第144行, init       代理文件“ C:\ Users \ Nino \ PycharmProjects \ Instagram \ venv \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py”,   第157行,在 init       self.start_session(功能,浏览器配置文件)文件“ C:\ Users \ Nino \ PycharmProjects \ Instagram \ venv \ lib \ site-packages \ appium \ webdriver \ webdriver.py”,   第219行,在start_session中       响应= self.execute(RemoteCommand.NEW_SESSION,参数)文件   “ C:\ Users \ Nino \ PycharmProjects \ Instagram \ venv \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py”,   第321行,在执行中       self.error_handler.check_response(响应)文件“ C:\ Users \ Nino \ PycharmProjects \ Instagram \ venv \ lib \ site-packages \ selenium \ webdriver \ remote \ errorhandler.py”,   第242行,在check_response中       引发exception_class(消息,屏幕,堆栈跟踪)selenium.common.exceptions.WebDriverException:消息:未知   处理命令时发生服务器端错误。原版的   错误:在[“ C:\ Program”中找不到'adb.exe'   Files \ Android \ platform-tools \ platform-tools \ adb.exe“,” C:\ Program   Files \ Android \ platform-tools \ emulator \ adb.exe“,” C:\ Program   Files \ Android \ platform-tools \ tools \ adb.exe“,” C:\ Program   Files \ Android \ platform-tools \ tools \ bin \ adb.exe“]。您是否拥有   Android Build Tools安装在'C:\ Program   Files \ Android \ platform-tools'?

     

断言失败   C:\ Users \ Nino \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ unittest \ case.py:656:   资源警告:未封闭
  result.errors.clear()ResourceWarning:启用tracemalloc以获取   对象分配回溯

     

在2.139秒内进行了1次测试

     

失败(错误= 1)

     

以退出代码1完成的过程

     

断言失败

     

断言失败

我正在使用pycharm。当我运行代码时,我看到一些错误日志,但是当我从cmd中运行它时,什么也没有。

enter image description here

这是Appium日志的主要部分:

>     Android >= 6, since UIAutomator1 framework is not maintained anymore by the OS vendor.
>         [Appium] Appium v1.13.0 creating new AndroidDriver (v4.15.1) session
>         [Appium] Capabilities:
>         [Appium]   platformName: Android
>         [Appium]   platformVersion: 6.0
>         [Appium]   deviceName: S6S5IN3G
>         [Appium]   noReset: true
>         [Appium]   appPackage: com.instagram
>         [Appium]   appActivity: com.instagram.android.activity.MainTabActivity
>         [BaseDriver] W3C capabilities {"alwaysMatch":{"platformNa... and MJSONWP desired capabilities {"platformName":"Android","... were
> provided
>         [BaseDriver] Creating session with W3C capabilities: {"alwaysMatch":{"platformNa...
>         [BaseDriver] Capability 'noReset' changed from string to boolean. This may cause unexpected behavior
>         [BaseDriver] Session created with session id: 786ec1a0-280c-4573-a917-18df120f0629
>         [AndroidDriver] Shutting down Android driver
>         [AndroidDriver] Called deleteSession but bootstrap wasn't active
>         [BaseDriver] Event 'newSessionStarted' logged at 1566428435932 (01:00:35 GMT+0200 (Paris, Madrid (heure d’été)))
>         [W3C] Encountered internal error running command: Error: Could not find 'adb.exe' in ["C:\\Program
> Files\\Android\\platform-tools\\platform-tools\\adb.exe","C:\\Program
> Files\\Android\\platform-tools\\emulator\\adb.exe","C:\\Program
> Files\\Android\\platform-tools\\tools\\adb.exe","C:\\Program
> Files\\Android\\platform-tools\\tools\\bin\\adb.exe"]. Do you have
> Android Build Tools installed at 'C:\Program
> Files\Android\platform-tools'?
>         [W3C]     at ADB. (C:\Users\Nino\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\system-calls.js:106:11)
>         [W3C]     at Generator.next ()
>         [W3C]     at asyncGeneratorStep (C:\Users\Nino\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)
>         [W3C]     at _next (C:\Users\Nino\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)
>         [W3C]     at run (C:\Users\Nino\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\core-js\modules\es6.promise.js:75:22)
>         [W3C]     at C:\Users\Nino\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\core-js\modules\es6.promise.js:92:30
>         [W3C]     at flush (C:\Users\Nino\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\core-js\modules\_microtask.js:18:9)
>         [W3C]     at process._tickCallback (internal/process/next_tick.js:61:11)
>         [HTTP] <-- POST /wd/hub/session 500 49 ms - 1544
>         [HTTP]

有人可以建议我一些解决方案吗?

谢谢你。

1 个答案:

答案 0 :(得分:1)

您需要在操作系统PATH中拥有adb.exe

我建议进行以下设置:

  1. 创建指向您的Android SDK安装的ANDROID_HOME环境变量
  2. 创建指向您的JDK安装的JAVA_HOME环境变量
  3. 创建PATH环境变量,例如:

    %ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%JAVA_HOME%\bin
    

    enter image description here

  4. 这足以成功启动Python Appium测试

您始终可以使用appium-doctor工具来检查Appium必备组件安装的完整性。

更多信息: