You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import unittest
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy
class TestAppium(unittest.TestCase):
def setUp(self) -> None:
self.driver = webdriver.Remote(appium_server_url, options=UiAutomator2Options().load_capabilities(capabilities))
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()
C:\Users\Admin\Desktop>appium server
[Appium] Welcome to Appium v2.5.1
[Appium] The autodetected Appium home path: C:\Users\Admin.appium
[Appium] Attempting to load driver xcuitest...
[Appium] Attempting to load driver uiautomator2...
[Appium] Requiring driver at C:\Users\Admin.appium\node_modules\appium-uiautomator2-driver\build\index.js
[Appium] Requiring driver at C:\Users\Admin.appium\node_modules\appium-xcuitest-driver\build\index.js
[Appium] AndroidUiautomator2Driver has been successfully loaded in 1.493s
[Appium] XCUITestDriver has been successfully loaded in 1.493s
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLs in your client code to connect to this server:
[Appium] http://10.11.8.242:4723/
[Appium] http://192.168.56.1:4723/
[Appium] http://192.168.0.102:4723/
[Appium] http://127.0.0.1:4723/ (only accessible from the same host)
[Appium] http://172.17.32.1:4723/
[Appium] Available drivers:
[Appium] - xcuitest@7.5.4 (automationName 'XCUITest')
[Appium] - uiautomator2@3.0.5 (automationName 'UiAutomator2')
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.
C:\Users\Admin\pythonProject1\venv\Scripts\python.exe "C:/Program Files/JetBrains/PyCharm 2023.2.3/plugins/python/helpers/pycharm/_jb_unittest_runner.py" --path C:\Users\Admin\pythonProject1\123.py
Testing started at 17:16 ...
Launching unittests with arguments python -m unittest C:\Users\Admin\pythonProject1\123.py in C:\Users\Admin\pythonProject1
Error
Traceback (most recent call last):
File "C:\Users\Admin\pythonProject1\123.py", line 21, in setUp
self.driver = webdriver.Remote(appium_server_url, options=UiAutomator2Options().load_capabilities(capabilities))
File "C:\Users\Admin\pythonProject1\venv\lib\site-packages\appium\webdriver\webdriver.py", line 229, in init
super().init(
File "C:\Users\Admin\pythonProject1\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 208, in init
self.start_session(capabilities)
File "C:\Users\Admin\pythonProject1\venv\lib\site-packages\appium\webdriver\webdriver.py", line 320, in start_session
response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
File "C:\Users\Admin\pythonProject1\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 347, in execute
self.error_handler.check_response(response)
File "C:\Users\Admin\pythonProject1\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
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
import unittest
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy
capabilities = dict(
platformName='Android',
automationName='uiautomator2',
deviceName='Android',
appPackage='com.android.settings',
appActivity='.Settings',
language='en',
locale='US'
)
appium_server_url = "http://127.0.0.1:4723/"
class TestAppium(unittest.TestCase):
def setUp(self) -> None:
self.driver = webdriver.Remote(appium_server_url, options=UiAutomator2Options().load_capabilities(capabilities))
if name == 'main':
unittest.main()
C:\Users\Admin\Desktop>appium server
[Appium] Welcome to Appium v2.5.1
[Appium] The autodetected Appium home path: C:\Users\Admin.appium
[Appium] Attempting to load driver xcuitest...
[Appium] Attempting to load driver uiautomator2...
[Appium] Requiring driver at C:\Users\Admin.appium\node_modules\appium-uiautomator2-driver\build\index.js
[Appium] Requiring driver at C:\Users\Admin.appium\node_modules\appium-xcuitest-driver\build\index.js
[Appium] AndroidUiautomator2Driver has been successfully loaded in 1.493s
[Appium] XCUITestDriver has been successfully loaded in 1.493s
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLs in your client code to connect to this server:
[Appium] http://10.11.8.242:4723/
[Appium] http://192.168.56.1:4723/
[Appium] http://192.168.0.102:4723/
[Appium] http://127.0.0.1:4723/ (only accessible from the same host)
[Appium] http://172.17.32.1:4723/
[Appium] Available drivers:
[Appium] - xcuitest@7.5.4 (automationName 'XCUITest')
[Appium] - uiautomator2@3.0.5 (automationName 'UiAutomator2')
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.
C:\Users\Admin\pythonProject1\venv\Scripts\python.exe "C:/Program Files/JetBrains/PyCharm 2023.2.3/plugins/python/helpers/pycharm/_jb_unittest_runner.py" --path C:\Users\Admin\pythonProject1\123.py
Testing started at 17:16 ...
Launching unittests with arguments python -m unittest C:\Users\Admin\pythonProject1\123.py in C:\Users\Admin\pythonProject1
Error
Traceback (most recent call last):
File "C:\Users\Admin\pythonProject1\123.py", line 21, in setUp
self.driver = webdriver.Remote(appium_server_url, options=UiAutomator2Options().load_capabilities(capabilities))
File "C:\Users\Admin\pythonProject1\venv\lib\site-packages\appium\webdriver\webdriver.py", line 229, in init
super().init(
File "C:\Users\Admin\pythonProject1\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 208, in init
self.start_session(capabilities)
File "C:\Users\Admin\pythonProject1\venv\lib\site-packages\appium\webdriver\webdriver.py", line 320, in start_session
response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
File "C:\Users\Admin\pythonProject1\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 347, in execute
self.error_handler.check_response(response)
File "C:\Users\Admin\pythonProject1\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
Ran 1 test in 0.030s
FAILED (errors=1)
Process finished with exit code 1
Beta Was this translation helpful? Give feedback.
All reactions