Why can't I run an Appium server in python?

115 views Asked by At

I use Python to write Appium scripts to automate my mobile application, but when I run it, my code error.

Here is my code

`from appium import webdriver from appium.webdriver.appium_service import AppiumService from appium.options.android import UiAutomator2Options

appium_service = AppiumService()

appium_service.start(args=["-p", "4723"])

desired_cap = { "deviceName": "emulator", "platformName": "Android" }

options = UiAutomator2Options().load_capabilities(desired_cap) driver = webdriver.Remote(command_executor="http://127.0.0.1:4723/wd/hub", options=options)

appium_service.stop()`

When I try to run it show error message

Traceback (most recent call last): File "C:\Users\Phan Phanit\PycharmProjects\appium\test3.py", line 17, in driver = webdriver.Remote(command_executor="http://127.0.0.1:4723/wd/hub", options=options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Phan Phanit\PycharmProjects\appium\venv\Lib\site-packages\appium\webdriver\webdriver.py", line 229, in init super().init( File "C:\Users\Phan Phanit\PycharmProjects\appium\venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 205, in init self.start_session(capabilities) File "C:\Users\Phan Phanit\PycharmProjects\appium\venv\Lib\site-packages\appium\webdriver\webdriver.py", line 318, in start_session response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Phan Phanit\PycharmProjects\appium\venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 344, in execute self.error_handler.check_response(response) File "C:\Users\Phan Phanit\PycharmProjects\appium\venv\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, 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

How to solve this problem? Thanks in advance for the answer.

0

There are 0 answers