本文整理汇总了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)
示例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
示例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()
示例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