Created
January 24, 2024 07:08
-
-
Save apatheticL/d3a477dee2520ac6ea96dc1b3e7ebbe2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\learn\PythonProject\.venv\Scripts\python.exe "C:/Program Files/JetBrains/PyCharm 2023.3.2/plugins/python/helpers/pycharm/_jb_pytest_runner.py" --path D:\learn\PythonProject\Tests\LauchApp.py | |
Testing started at 2:07 PM ... | |
Launching pytest with arguments D:\learn\PythonProject\Tests\LauchApp.py --no-header --no-summary -q in D:\learn\PythonProject\Tests | |
============================= test session starts ============================= | |
collecting ... collected 1 item | |
LauchApp.py::TestAppium::test_find_battery | |
============================== 1 failed in 2.24s ============================== | |
FAILED [100%] | |
LauchApp.py:28 (TestAppium.test_find_battery) | |
self = <LauchApp.TestAppium testMethod=test_find_battery> | |
def setUp(self) -> None: | |
> self.driver = webdriver.Remote(command_executor=appium_server_url, options=capabilities_options) | |
LauchApp.py:23: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
..\.venv\Lib\site-packages\appium\webdriver\webdriver.py:229: in __init__ | |
super().__init__( | |
..\.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py:208: in __init__ | |
self.start_session(capabilities) | |
..\.venv\Lib\site-packages\appium\webdriver\webdriver.py:321: in start_session | |
response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps) | |
..\.venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py:347: in execute | |
self.error_handler.check_response(response) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002A9CE5A1E20> | |
response = {'status': 404, 'value': "The URL '/session' did not map to a valid resource"} | |
def check_response(self, response: Dict[str, Any]) -> None: | |
"""Checks that a JSON response from the WebDriver does not have an | |
error. | |
:Args: | |
- response - The JSON response from the WebDriver server as a dictionary | |
object. | |
:Raises: If the response contains an error message. | |
""" | |
status = response.get("status", None) | |
if not status or status == ErrorCode.SUCCESS: | |
return | |
value = None | |
message = response.get("message", "") | |
screen: str = response.get("screen", "") | |
stacktrace = None | |
if isinstance(status, int): | |
value_json = response.get("value", None) | |
if value_json and isinstance(value_json, str): | |
import json | |
try: | |
value = json.loads(value_json) | |
if len(value) == 1: | |
value = value["value"] | |
status = value.get("error", None) | |
if not status: | |
status = value.get("status", ErrorCode.UNKNOWN_ERROR) | |
message = value.get("value") or value.get("message") | |
if not isinstance(message, str): | |
value = message | |
message = message.get("message") | |
else: | |
message = value.get("message", None) | |
except ValueError: | |
pass | |
exception_class: Type[WebDriverException] | |
e = ErrorCode() | |
error_codes = [item for item in dir(e) if not item.startswith("__")] | |
for error_code in error_codes: | |
error_info = getattr(ErrorCode, error_code) | |
if isinstance(error_info, list) and status in error_info: | |
exception_class = getattr(ExceptionMapping, error_code, WebDriverException) | |
break | |
else: | |
exception_class = WebDriverException | |
if not value: | |
value = response["value"] | |
if isinstance(value, str): | |
> raise exception_class(value) | |
E selenium.common.exceptions.WebDriverException: Message: The URL '/session' did not map to a valid resource | |
..\.venv\Lib\site-packages\selenium\webdriver\remote\errorhandler.py:193: WebDriverException | |
Process finished with exit code 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment