diff --git a/appium/webdriver/extensions/execute_driver.py b/appium/webdriver/extensions/execute_driver.py index aa479ed8..64aae818 100644 --- a/appium/webdriver/extensions/execute_driver.py +++ b/appium/webdriver/extensions/execute_driver.py @@ -20,8 +20,19 @@ class ExecuteDriver(CanExecuteCommands): - # TODO Inner class case - def execute_driver(self, script: str, script_type: str = 'webdriverio', timeout_ms: int | None = None) -> Any: + class Result: + """The result of ``execute_driver``, containing ``result`` and ``logs``.""" + + result: Any + logs: dict[str, list[Any]] + + def __init__(self, res: dict[str, Any]) -> None: + self.result = res['result'] + self.logs = res['logs'] + + def execute_driver( + self, script: str, script_type: str = 'webdriverio', timeout_ms: int | None = None + ) -> 'ExecuteDriver.Result': """Run a set of script against the current session, allowing execution of many commands in one Appium request. Please read http://appium.io/docs/en/commands/session/execute-driver for more details about the acceptable scripts and the output format. @@ -43,18 +54,12 @@ def execute_driver(self, script: str, script_type: str = 'webdriverio', timeout_ Raises: WebDriverException: If something error happens in the script. The message has the original error message. """ - - class Result: - def __init__(self, res: dict): - self.result = res['result'] - self.logs = res['logs'] - option: dict[str, str | int] = {'script': script, 'type': script_type} if timeout_ms is not None: option['timeout'] = timeout_ms response = self.execute(Command.EXECUTE_DRIVER, option)['value'] - return Result(response) + return ExecuteDriver.Result(response) def _add_commands(self) -> None: self.command_executor.add_command(Command.EXECUTE_DRIVER, 'POST', '/session/$sessionId/appium/execute_driver') diff --git a/appium/webdriver/extensions/screen_record.py b/appium/webdriver/extensions/screen_record.py index 418b79e6..97ed2bc7 100644 --- a/appium/webdriver/extensions/screen_record.py +++ b/appium/webdriver/extensions/screen_record.py @@ -188,10 +188,12 @@ def stop_recording_screen(self, **options: Any) -> bytes: headers (dict): [multipart/form-data requests] Headers mapping (Since Appium 1.18.0) Usage: - payload = driver.stop_recording_screen() - with open('media.mp4', "wb") as fd: - import base64 - fd.write(base64.b64decode(payload)) + .. code-block:: python + + payload = driver.stop_recording_screen() + with open('media.mp4', "wb") as fd: + import base64 + fd.write(base64.b64decode(payload)) Returns: bytes: Base-64 encoded content of the recorded media file or an empty string diff --git a/docs/conf.py b/docs/conf.py index 10f4c7fb..5e4f36e1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -50,9 +50,8 @@ # html_theme = 'sphinx_rtd_theme' -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - add_module_names = False + +autodoc_default_options = { + 'exclude-members': 'T', +} diff --git a/docs/generate.sh b/docs/generate.sh index 71131e83..fc0b91a2 100644 --- a/docs/generate.sh +++ b/docs/generate.sh @@ -1,4 +1,4 @@ #!/bin/sh rm -rf *rst _build -uv run sphinx-apidoc -F -H 'Appium python client' -o . ../appium/webdriver +uv run sphinx-apidoc -F -H 'Appium python client' -o . ../appium/webdriver ../appium/webdriver/mobilecommand.py make html diff --git a/docs/index.rst b/docs/index.rst index 9c16ec4d..9e32b51c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -6,9 +6,7 @@ Appium python client documentation ================================== -Add your content using ``reStructuredText`` syntax. See the -`reStructuredText `_ -documentation for details. +API reference documentation for `Appium-Python-Client `_. .. toctree:: diff --git a/docs/webdriver.rst b/docs/webdriver.rst index f74a7db8..9a7fb2f2 100644 --- a/docs/webdriver.rst +++ b/docs/webdriver.rst @@ -85,14 +85,6 @@ webdriver.locator\_converter module :show-inheritance: :undoc-members: -webdriver.mobilecommand module ------------------------------- - -.. automodule:: webdriver.mobilecommand - :members: - :show-inheritance: - :undoc-members: - webdriver.switch\_to module --------------------------- @@ -124,3 +116,4 @@ Module contents :members: :show-inheritance: :undoc-members: + :no-index: diff --git a/test/unit/webdriver/execute_driver_test.py b/test/unit/webdriver/execute_driver_test.py index 65cdbbd2..ed113049 100644 --- a/test/unit/webdriver/execute_driver_test.py +++ b/test/unit/webdriver/execute_driver_test.py @@ -16,6 +16,7 @@ import httpretty +from appium.webdriver.extensions.execute_driver import ExecuteDriver from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body @@ -40,6 +41,7 @@ def test_batch(self): return [element, rect]; """ response = driver.execute_driver(script=textwrap.dedent(script)) + assert isinstance(response, ExecuteDriver.Result) # Python client convert an element item as WebElement in the result assert response.result[0].id == '39000000-0000-0000-D39A-000000000000' assert response.result[1]['y'] == 237