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


Python Context.in_robot方法代码示例

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


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

示例1: __init__

# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import in_robot [as 别名]
    def __init__(self):
        for base in Page.__bases__:
            base.__init__(self)
        self._robot_handler = RobotHandler(self)
        self._option_handler = OptionHandler(self)
        self._yaml_handler = YAMLHandler(self)

        try:
            self.name
        except AttributeError:
            self.name = self._titleize(self.__class__.__name__)

        # Required Attributes in options ##
        self.browser = self._option_handler.get("browser", None)
        self.baseurl = self._option_handler.get("baseurl", None)

        # Setting Up Optional Selenium2Library attributes with OptionHandler ##
        selenium_speed = self._option_handler.get("selenium_speed", 0)
        selenium_implicit_wait = self._option_handler.get("selenium_implicit_wait", 5)

        self.set_selenium_timeout(selenium_implicit_wait)
        self.set_selenium_implicit_wait(selenium_implicit_wait)
        self.set_selenium_speed(selenium_speed)

        _shared_cache = Context.get_cache()
        if _shared_cache is not None:
            self._cache = _shared_cache
        Context.set_cache(self._cache)

        if Context.in_robot():
            Context.set_current_page("pageobjects.Page")
        KeywordManager().add_page_methods(self)
开发者ID:charleshamel73,项目名称:robot-pageobjects,代码行数:34,代码来源:page.py

示例2: __init__

# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import in_robot [as 别名]
    def __init__(self):
        self.in_robot = Context.in_robot()
        self.formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
        self.threshold_level_as_str = self.get_threshold_level_as_str()
        self.threshold_level_as_int = self.get_log_level_from_str(self.threshold_level_as_str)

        if self.in_robot:
            self.logger = robot.api.logger
        else:

            # Stream handler is attached from log() since
            # that must be decided at run-time, but here we might as well
            # do the setup to keep log() clean.
            self.stream_handler = logging.StreamHandler(sys.stdout)
            self.stream_handler.setFormatter(self.formatter)

            # We have to instantiate a logger to something and this is a global
            # logger so we name it by this class. Later in this class'
            # log method, we manipulate the msg string to include the calling
            # page class name.
            logger = logging.getLogger(self.__class__.__name__)
            logger.setLevel(self.threshold_level_as_int)
            fh = logging.FileHandler("po_log.txt", "w")
            fh.setLevel(self.threshold_level_as_int)
            fh.setFormatter(self.formatter)
            logger.addHandler(fh)
            self.logger = logger
开发者ID:guykisel,项目名称:robotframework-pageobjects,代码行数:29,代码来源:abstractedlogger.py

示例3: _populate_opts

# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import in_robot [as 别名]
 def _populate_opts(self):
     """
     Pulls environment from PO_ environment file
     """
     self._opts.update(self._get_opts_from_var_file())
     self._opts.update(self._get_opts_from_env_vars())
     if Context.in_robot():
         self._opts.update(self._get_opts_from_robot())
     self._update_opts_from_inherited_classes()
开发者ID:charleshamel73,项目名称:robot-pageobjects,代码行数:11,代码来源:optionhandler.py

示例4: get

# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import in_robot [as 别名]
    def get(self, name, default=None):
        """
        Gets an option value given an option name

        :param name: The name of the option to get
        :type name: str
        :param default: the value to return if none is found
        :type default: any
        :return: the value of the attribute or default if not found
        """
        ret = default
        try:
            if Context.in_robot():
                ret = self._opts[self._normalize(name)]
            else:
                ret = self._opts[self._normalize(name.replace(" ", "_"))]
        except KeyError:
            pass
        return ret
开发者ID:charleshamel73,项目名称:robot-pageobjects,代码行数:21,代码来源:optionhandler.py


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