当前位置: 首页>>代码示例>>Python>>正文


Python ErrorHandler.check_response方法代码示例

本文整理汇总了Python中errorhandler.ErrorHandler.check_response方法的典型用法代码示例。如果您正苦于以下问题:Python ErrorHandler.check_response方法的具体用法?Python ErrorHandler.check_response怎么用?Python ErrorHandler.check_response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在errorhandler.ErrorHandler的用法示例。


在下文中一共展示了ErrorHandler.check_response方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: WebDriver

# 需要导入模块: from errorhandler import ErrorHandler [as 别名]
# 或者: from errorhandler.ErrorHandler import check_response [as 别名]

#.........这里部分代码省略.........
    def create_web_element(self, element_id):
        """
        Creates a web element with the specified element_id.
        """
        return WebElement(self, element_id)

    def _unwrap_value(self, value):
        if isinstance(value, dict) and 'ELEMENT' in value:
            return self.create_web_element(value['ELEMENT'])
        elif isinstance(value, list):
            return list(self._unwrap_value(item) for item in value)
        else:
            return value

    def execute(self, driver_command, params=None):
        """
        Sends a command to be executed by a command.CommandExecutor.

        :Args:
         - driver_command: The name of the command to execute as a string.
         - params: A dictionary of named parameters to send with the command.

        :Returns:
          The command's JSON response loaded into a dictionary object.
        """
        if not params:
            params = {'sessionId': self.session_id}
        elif 'sessionId' not in params:
            params['sessionId'] = self.session_id

        params = self._wrap_value(params)
        response = self.command_executor.execute(driver_command, params)
        if response:
            self.error_handler.check_response(response)
            response['value'] = self._unwrap_value(
                response.get('value', None))
            return response
        # If the server doesn't send a response, assume the command was
        # a success
        return {'success': 0, 'value': None, 'sessionId': self.session_id}

    def get(self, url):
        """
        Loads a web page in the current browser session.
        """
        self.execute(Command.GET, {'url': url})

    @property
    def title(self):
        """Returns the title of the current page.

        :Usage:
            driver.title
        """
        resp = self.execute(Command.GET_TITLE)
        return resp['value'] if resp['value'] is not None else ""

    def find_element_by_id(self, id_):
        """Finds an element by id.

        :Args:
         - id\_ - The id of the element to be found.

        :Usage:
            driver.find_element_by_id('foo')
        """
开发者ID:aking1012,项目名称:stackChat,代码行数:70,代码来源:webdriver.py

示例2: WebDriver

# 需要导入模块: from errorhandler import ErrorHandler [as 别名]
# 或者: from errorhandler.ErrorHandler import check_response [as 别名]

#.........这里部分代码省略.........
            return list(self._wrap_value(item) for item in value)
        else:
            return value
            
    def create_web_element(self, element_id):
        return WebElement(self, element_id)

    def _unwrap_value(self, value):
        if isinstance(value, dict) and 'ELEMENT' in value:
            return self.create_web_element(value['ELEMENT'])
        elif isinstance(value, list):
            return list(self._unwrap_value(item) for item in value)
        else:
            return value

    def execute(self, driver_command, params=None):
        """Sends a command to be executed by a command.CommandExecutor.

        Args:
          driver_command: The name of the command to execute as a string.
          params: A dictionary of named parameters to send with the command.

        Returns:
          The command's JSON response loaded into a dictionary object.
        """
        if not params:
            params = {'sessionId': self.session_id}
        elif 'sessionId' not in params:
            params['sessionId'] = self.session_id

        params = self._wrap_value(params)
        response = self.command_executor.execute(driver_command, params)
        if response:
            self.error_handler.check_response(response)
            response['value'] = self._unwrap_value(
                response.get('value', None))
            return response
        # If the server doesn't send a response, assume the command was
        # a success
        return {'success': 0, 'value': None}

    def get(self, url):
        """Loads a web page in the current browser."""
        self.execute(Command.GET, {'url': url})

    @property
    def title(self):
        """Gets the title of the current page."""
        resp = self.execute(Command.GET_TITLE)
        return resp['value'] if resp['value'] is not None else ""

    def find_element_by_id(self, id_):
        """Finds element by id."""
        return self.find_element(by=By.ID, value=id_)

    def find_elements_by_id(self, id_):
        """Finds element by id."""
        return self.find_elements(by=By.ID, value=id_)

    def find_elements_by_xpath(self, xpath):
        """Finds multiple elements by xpath."""
        return self.find_elements(by=By.XPATH, value=xpath)

    def find_element_by_xpath(self, xpath):
        """Finds an element by xpath."""
        return self.find_element(by=By.XPATH, value=xpath)
开发者ID:Escobita,项目名称:selenium,代码行数:70,代码来源:webdriver.py

示例3: WebDriver

# 需要导入模块: from errorhandler import ErrorHandler [as 别名]
# 或者: from errorhandler.ErrorHandler import check_response [as 别名]

#.........这里部分代码省略.........
        elif isinstance(value, list):
            return list(self._wrap_value(item) for item in value)
        else:
            return value

    def create_web_element(self, element_id):
        """Creates a web element with the specified element_id."""
        return WebElement(self, element_id)

    def _unwrap_value(self, value):
        if isinstance(value, dict) and "ELEMENT" in value:
            return self.create_web_element(value["ELEMENT"])
        elif isinstance(value, list):
            return list(self._unwrap_value(item) for item in value)
        else:
            return value

    def execute(self, driver_command, params=None):
        """Sends a command to be executed by a command.CommandExecutor.
        Args:
          driver_command: The name of the command to execute as a string.
          params: A dictionary of named parameters to send with the command.
        Returns:
          The command's JSON response loaded into a dictionary object.
        """
        if not params:
            params = {"sessionId": self.session_id}
        elif "sessionId" not in params:
            params["sessionId"] = self.session_id

        params = self._wrap_value(params)
        response = self.command_executor.execute(driver_command, params)
        if response:
            self.error_handler.check_response(response)
            response["value"] = self._unwrap_value(response.get("value", None))
            return response
        # If the server doesn't send a response, assume the command was
        # a success
        return {"success": 0, "value": None}

    def get(self, url):
        """Loads a web page in the current browser session."""
        self.execute(Command.GET, {"url": url})

    @property
    def title(self):
        """Returns the title of the current page.
        Usage:
            driver.title
        """
        resp = self.execute(Command.GET_TITLE)
        return resp["value"] if resp["value"] is not None else ""

    def find_element_by_id(self, id_):
        """Finds an element by id.
        Args:
            id_: The id of the element to be found.
        Usage:
            driver.find_element_by_id('foo')
        """
        return self.find_element(by=By.ID, value=id_)

    def find_elements_by_id(self, id_):
        """Finds multiple elements by id.
        Args:
            id_: The id of the elements to be found.
开发者ID:antlong,项目名称:jellypy,代码行数:70,代码来源:webdriver.py

示例4: WebDriver

# 需要导入模块: from errorhandler import ErrorHandler [as 别名]
# 或者: from errorhandler.ErrorHandler import check_response [as 别名]

#.........这里部分代码省略.........
            return list(self._wrap_value(item) for item in value)
        else:
            return value
            
    def create_web_element(self, element_id):
        return WebElement(self, element_id)

    def _unwrap_value(self, value):
        if isinstance(value, dict) and 'ELEMENT' in value:
            return self.create_web_element(value['ELEMENT'])
        elif isinstance(value, list):
            return list(self._unwrap_value(item) for item in value)
        else:
            return value

    def _execute(self, driver_command, params=None):
        """Sends a command to be executed by a command.CommandExecutor.

        Args:
          driver_command: The name of the command to execute as a string.
          params: A dictionary of named parameters to send with the command.

        Returns:
          The command's JSON response loaded into a dictionary object.
        """
        if not params:
            params = {'sessionId': self.session_id}
        elif 'sessionId' not in params:
            params['sessionId'] = self.session_id

        params = self._wrap_value(params)
        response = self.command_executor.execute(driver_command, params)
        if response:
            self.error_handler.check_response(response)
            response['value'] = self._unwrap_value(
                response.get('value', None))
            return response
        # If the server doesn't send a response, assume the command was
        # a success
        return {'success': 0, 'value': None}

    def get(self, url):
        """Loads a web page in the current browser."""
        self._execute(Command.GET, {'url': url})

    def get_title(self):
        """Gets the title of the current page."""
        resp = self._execute(Command.GET_TITLE)
        return resp['value']

    def find_element_by_id(self, id_):
        """Finds element by id."""
        return self._find_element_by("id", id_)

    def find_elements_by_xpath(self, xpath):
        """Finds multiple elements by xpath."""
        return self._find_elements_by("xpath", xpath)

    def find_element_by_xpath(self, xpath):
        """Finds an element by xpath."""
        return self._find_element_by("xpath", xpath)

    def find_element_by_link_text(self, link_text):
        """Finds an element by its link text."""
        return self._find_element_by("link text", link_text)
        
开发者ID:hugs,项目名称:selenium,代码行数:69,代码来源:webdriver.py

示例5: WebDriver

# 需要导入模块: from errorhandler import ErrorHandler [as 别名]
# 或者: from errorhandler.ErrorHandler import check_response [as 别名]

#.........这里部分代码省略.........
            return list(self._wrap_value(item) for item in value)
        else:
            return value

    def create_web_element(self, element_id):
        return WebElement(self, element_id)

    def _unwrap_value(self, value):
        if isinstance(value, dict) and "ELEMENT" in value:
            return self.create_web_element(value["ELEMENT"])
        elif isinstance(value, list):
            return list(self._unwrap_value(item) for item in value)
        else:
            return value

    def execute(self, driver_command, params=None):
        """Sends a command to be executed by a command.CommandExecutor.

        Args:
          driver_command: The name of the command to execute as a string.
          params: A dictionary of named parameters to send with the command.

        Returns:
          The command's JSON response loaded into a dictionary object.
        """
        if not params:
            params = {"sessionId": self.session_id}
        elif "sessionId" not in params:
            params["sessionId"] = self.session_id

        params = self._wrap_value(params)
        response = self.command_executor.execute(driver_command, params)
        if response:
            self.error_handler.check_response(response)
            response["value"] = self._unwrap_value(response.get("value", None))
            return response
        # If the server doesn't send a response, assume the command was
        # a success
        return {"success": 0, "value": None}

    def get(self, url):
        """Loads a web page in the current browser."""
        self.execute(Command.GET, {"url": url})

    @property
    def title(self):
        """Gets the title of the current page."""
        resp = self.execute(Command.GET_TITLE)
        return resp["value"] if resp["value"] is not None else ""

    def find_element_by_id(self, id_):
        """Finds element by id."""
        return self.find_element(by=By.ID, value=id_)

    def find_elements_by_id(self, id_):
        """Finds element by id."""
        return self.find_elements(by=By.ID, value=id_)

    def find_elements_by_xpath(self, xpath):
        """Finds multiple elements by xpath."""
        return self.find_elements(by=By.XPATH, value=xpath)

    def find_element_by_xpath(self, xpath):
        """Finds an element by xpath."""
        return self.find_element(by=By.XPATH, value=xpath)
开发者ID:vickkyy,项目名称:selenium,代码行数:69,代码来源:webdriver.py


注:本文中的errorhandler.ErrorHandler.check_response方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。