diff --git a/appium/webdriver/appium_service.py b/appium/webdriver/appium_service.py index d2aedadb..8aecc145 100644 --- a/appium/webdriver/appium_service.py +++ b/appium/webdriver/appium_service.py @@ -104,7 +104,7 @@ def _get_main_script(self) -> Union[str, bytes]: '-e', 'console.log(require.resolve("{}"))'.format(MAIN_SCRIPT_PATH)]).strip() except sp.CalledProcessError as e: - raise AppiumServiceError(e.output) + raise AppiumServiceError(e.output) from e return self._main_script @staticmethod diff --git a/appium/webdriver/errorhandler.py b/appium/webdriver/errorhandler.py index 11359e4d..8612d86a 100644 --- a/appium/webdriver/errorhandler.py +++ b/appium/webdriver/errorhandler.py @@ -26,6 +26,6 @@ def check_response(self, response: Dict) -> None: super().check_response(response) except WebDriverException as wde: if wde.msg == 'No such context found.': - raise NoSuchContextException(wde.msg, wde.screen, wde.stacktrace) + raise NoSuchContextException(wde.msg, wde.screen, wde.stacktrace) from wde else: raise wde diff --git a/appium/webdriver/extensions/remote_fs.py b/appium/webdriver/extensions/remote_fs.py index 4f8ff871..9176f710 100644 --- a/appium/webdriver/extensions/remote_fs.py +++ b/appium/webdriver/extensions/remote_fs.py @@ -73,9 +73,9 @@ def push_file(self, destination_path: str, try: with open(source_path, 'rb') as f: file_data = f.read() - except IOError: + except IOError as e: message = f'source_path "{source_path}" could not be found. Are you sure the file exists?' - raise InvalidArgumentException(message) + raise InvalidArgumentException(message) from e base64data = base64.b64encode(file_data).decode('utf-8') data = {