Gauthier Buttez
Gauthier Buttez

Reputation: 1193

Could not find 'adb.exe' in ......?

How to fix Could not find 'adb.exe'?

I think my question is one of the most asked and answered question of the Android world. I read and tried them all.

In fact I spent all the day by searching, reading and testing all the solution possible.

And nothing fixed my problem. So I really need your help.

I am newbie and I want to share my experience. Here is my code:

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)

This is the errors:

Testing started at 01:00 ... C:\Users\Nino\PycharmProjects\Instagram\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.3\helpers\pycharm_jb_unittest_runner.py" --target mybot_instagram.Instagram.test_scrap_email Launching unittests with arguments python -m unittest mybot_instagram.Instagram.test_scrap_email in C:\Users\Nino\PycharmProjects\Instagram

Error Traceback (most recent call last): File "C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\unittest\case.py", line 59, in testPartExecutor yield File "C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\unittest\case.py", line 624, in run self.setUp() File "C:\Users\Nino\PycharmProjects\Instagram\mybot_instagram.py", line 17, in setUp self.driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps) File "C:\Users\Nino\PycharmProjects\Instagram\venv\lib\site-packages\appium\webdriver\webdriver.py", line 144, in init proxy File "C:\Users\Nino\PycharmProjects\Instagram\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "C:\Users\Nino\PycharmProjects\Instagram\venv\lib\site-packages\appium\webdriver\webdriver.py", line 219, in start_session response = self.execute(RemoteCommand.NEW_SESSION, parameters) File "C:\Users\Nino\PycharmProjects\Instagram\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\Nino\PycharmProjects\Instagram\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original 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'?

Assertion failed C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\unittest\case.py:656: ResourceWarning: unclosed
outcome.errors.clear() ResourceWarning: Enable tracemalloc to get the object allocation traceback

Ran 1 test in 2.139s

FAILED (errors=1)

Process finished with exit code 1

Assertion failed

Assertion failed

I am using pycharm. When I run the code I see some error log, but when I run it from cmd, there is nothing.

enter image description here

And here the main part of Appium log:

>     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]

Can anyone suggest me some solutions please?

THank you.

Upvotes: 1

Views: 9914

Answers (1)

Dmitri T
Dmitri T

Reputation: 168157

You need to have adb.exe in your operating system PATH

I would recommend going for the following setup:

  1. Create ANDROID_HOME environment variable pointing to your Android SDK installation
  2. Create JAVA_HOME environment variable pointing to your JDK installation
  3. Create PATH environment variable like:

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

    enter image description here

  4. That should be sufficient to successfully launch your Python Appium test

You can always use appium-doctor tool in order to check the integrity of your Appium pre-requisites installation.

More information:

Upvotes: 5

Related Questions