Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #949

Closed
apatheticL opened this issue Jan 24, 2024 · 8 comments

Comments

@apatheticL
Copy link

The problem

I try example for text of appium in this link : https://appium.io/docs/en/2.4/quickstart/test-py/ . but it not work and show error
self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000001EFC51A8EC0>
response = {'status': 404, 'value': '{"status":9,"value":{"error":"unknown command","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","stacktrace":""}}'}
Please help me fix it. Thank so much,-.

Environment

  • Appium version (or git revision) that exhibits the issue:2.4.1
  • Desktop OS/version used to run Appium: Windown 11
  • Node.js version (unless using Appium.app|exe): v16.20.0
  • Mobile platform/version under test: Android 13
  • Real device or emulator/simulator: real device xiaomi node 11 pro
  • Appium CLI or Appium.app|exe: all, appium CLI and appium application same error

Link to Appium Logs

(https://gist.github.com/apatheticL/4f99a3ce0552b3a0e67f1efe14079c2a)

Code To reproduce issue

this is my code:
import unittest
from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
from appium.options.android import UiAutomator2Options

capabilities = dict(
platformName='Android',
automationName='uiautomator2',
deviceName='My device name',
appPackage='com.android.settings',
appActivity='.Settings',
# language='en',
# locale='US'
)

appium_server_url = 'http://localhost:4723/wd/hub'
APPIUM_PORT = 4723
APPIUM_HOST = '127.0.0.1'

capabilities_options = UiAutomator2Options().load_capabilities(capabilities)

class TestAppium(unittest.TestCase):
def setUp(self) -> None:
self.driver = webdriver.Remote(command_executor=appium_server_url, options=capabilities_options)

def tearDown(self) -> None:
    if self.driver:
        self.driver.quit()

def test_find_battery(self) -> None:
    el = self.driver.find_element(by=AppiumBy.XPATH, value='//*[@text="Battery"]')
    el.click()

if name == 'main':
unittest.main()

@KazuCocoa
Copy link
Member

What about using http://localhost:4723' as https://appium.io/docs/en/2.4/quickstart/test-py/ instead of http://localhost:4723/wd/hub?

@apatheticL
Copy link
Author

I try replace appium_server_url = 'http://localhost:4723/wd/hub'
to appium_server_url = 'http://localhost:4723' but it not work and it show same error you can see it in this link error https://gist.github.com/apatheticL/d3a477dee2520ac6ea96dc1b3e7ebbe2
Thanks

@KazuCocoa
Copy link
Member

Could you share the appium server log as well?

@apatheticL
Copy link
Author

Yes, this is log of appium server when i use
appium_server_url = 'http://localhost:4723/'
link log
https://gist.github.com/apatheticL/afa892c34e73f2cb86c0e0be1243b27d

@KazuCocoa
Copy link
Member

KazuCocoa commented Jan 24, 2024

Welcome to Appium v1.9.1

Please use the latest version. I'm not sure how you installed the Appium, but current Appium is v2.x and newer driver version. 1.9.1 is pretty old.

https://appium.io/docs/en/2.4/quickstart/install/
https://appium.io/docs/en/2.4/quickstart/uiauto2-driver/

@apatheticL
Copy link
Author

Thanks. but i remove this appium version 1.9.1 and i run it in appium version v2.4.1 but in appium server not show any error but in log build in IDE error in this link https://gist.github.com/apatheticL/476f75fcc7621ffaeb376350339d969c

@KazuCocoa
Copy link
Member

The error means your script failed to find the element. Possibly the device's screen did not have the matched element.
You may need to adjust the find element method's arguments. driver.page_source may help to see what elements are available in the screen.

This is how to write test code, so Appium is working right now

@s0unt
Copy link

s0unt commented May 26, 2024

appium_server_url = 'http://localhost:4723' WORKED only! instead of http://localhost:4723/wd/hub or http://localhost:4723/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants