Python Appium 无法远程模拟器

Python Appium Cannot Remote Emulator

我尝试 运行宁手动 appium 可以在 appium 检查器中打开我的模拟器,然后我尝试创建简单的脚本。这是我的脚本:

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)

但在 运行 之后脚本显示此错误:

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

我的脚本有什么问题?

appium 和 inspector 图片供参考 Appium Inspector Appium Server

不确定,但从您的日志中,尝试从 wd/hub/ 中删除最后一个 /

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