python-3.xseleniumappiumappium-android

Python Appium Cannot Remote Emulator


I was try running manual appium is work to open my emulator in appium inspector, and then i try create simple script. here is my script :

from appium import webdriver
import time

desired_capabilities = {}

desired_capabilities['appPackage'] = 'com.facebook.lite'
desired_capabilities['appActivity'] = 'com.facebook.lite.MainActivity'
desired_capabilities['platformName'] = 'Android'
desired_capabilities['deviceName'] = 'VirtualDevice'
desired_capabilities['udid'] = 'emulator-5554'

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub/', desired_capabilities)

but after run the script show this error :

Traceback (most recent call last):
  File "c:/Users/ATHAMZ-PC/Desktop/Python ADB/Python Bot/fb.py", line 12, in <module>
    driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub/', desired_capabilities)
  File "C:\Users\ATHAMZ-PC\AppData\Local\Programs\Python\Python37\lib\site-packages\appium\webdriver\webdriver.py", line 274, in __init__
    AppiumConnection(command_executor, keep_alive=keep_alive), desired_capabilities, browser_profile, proxy
  File "C:\Users\ATHAMZ-PC\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\ATHAMZ-PC\AppData\Local\Programs\Python\Python37\lib\site-packages\appium\webdriver\webdriver.py", line 364, in start_session
    response = self.execute(RemoteCommand.NEW_SESSION, parameters)
  File "C:\Users\ATHAMZ-PC\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 424, in execute
    self.error_handler.check_response(response)
  File "C:\Users\ATHAMZ-PC\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource

whats is wrong with my script?

appium and inspector image to reference Appium Inspector Appium Server


Solution

  • Not sure, but from your logs, try to remove the last / from wd/hub/.

    driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities)