本文整理汇总了Python中robot.api.logger.info方法的典型用法代码示例。如果您正苦于以下问题:Python logger.info方法的具体用法?Python logger.info怎么用?Python logger.info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类robot.api.logger
的用法示例。
在下文中一共展示了logger.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def __init__(self, server: str, user: str, password: str, run_id: str, protocol: str = 'http',
juggler_disable: str = None, update: str = None) -> None:
"""Listener initialization.
*Args:*\n
_server_ - name of TestRail server;\n
_user_ - name of TestRail user;\n
_password_ - password of TestRail user;\n
_run_id_ - ID of the test run;\n
_protocol_ - connecting protocol to TestRail server: http or https;\n
_juggler_disable_ - indicator to disable juggler logic; if exist, then juggler logic will be disabled;\n
_update_ - indicator to update test case in TestRail; if exist, then test will be updated.
"""
testrail_url = '{protocol}://{server}/testrail/'.format(protocol=protocol, server=server)
self._url = testrail_url + 'index.php?/api/v2/'
self._user = user
self._password = password
self.run_id = run_id
self.juggler_disable = juggler_disable
self.update = update
self.tr_client = TestRailAPIClient(server, user, password, run_id, protocol)
self._vars_for_report_link: Optional[Dict[str, str]] = None
logger.info('[TestRailListener] url: {testrail_url}'.format(testrail_url=testrail_url))
logger.info('[TestRailListener] user: {user}'.format(user=user))
logger.info('[TestRailListener] the ID of the test run: {run_id}'.format(run_id=run_id))
示例2: _update_case_description
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def _update_case_description(self, attributes: JsonDict, case_id: str, name: str,
references: Optional[str]) -> None:
""" Update test case description in TestRail
*Args:* \n
_attributes_ - attributes of test case in Robot Framework;\n
_case_id_ - case id;\n
_name_ - test case name;\n
_references_ - test references.
"""
logger.info(f"[TestRailListener] update of test {case_id} in TestRail")
description = f"{attributes['doc']}\nPath to test: {attributes['longname']}"
request_fields: Dict[str, Union[str, int, None]] = {
'title': name, 'type_id': self.TESTRAIL_CASE_TYPE_ID_AUTOMATED,
'custom_case_description': description, 'refs': references}
try:
json_result = self.tr_client.update_case(case_id, request_fields)
result = json.dumps(json_result, sort_keys=True, indent=4)
logger.info(f"[TestRailListener] result for method update_case: {result}")
except requests.HTTPError as error:
logger.error(f"[TestRailListener] http error, while execute request:\n{error}")
示例3: page_should_contain_string
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def page_should_contain_string(self, txt, ignore_case=False, error_message=None):
"""Search if a given string exists on the mainframe screen.
The search is case sensitive, if you want ignore this you can pass the argument: ignore_case=${True}
and you can edit the raise exception message with error_message.
Example:
| Page Should Contain String | something |
| Page Should Contain String | someTHING | ignore_case=${True} |
| Page Should Contain String | something | error_message=New error message |
"""
message = 'The string "' + txt + '" was not found'
if error_message: message = error_message
if ignore_case: txt = str(txt).lower()
result = self._search_string(txt, ignore_case)
if not result: raise Exception(message)
logger.info('The string "' + txt + '" was found')
示例4: page_should_contain_string_x_times
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def page_should_contain_string_x_times(self, txt, number, ignore_case=False, error_message=None):
"""Search if the entered string appears the desired number of times on the mainframe screen.
The search is case sensitive, if you want ignore this you can pass the argument: ignore_case=${True} and you
can edit the raise exception message with error_message.
Example:
| Page Should Contain String X Times | something | 3 |
| Page Should Contain String X Times | someTHING | 3 | ignore_case=${True} |
| Page Should Contain String X Times | something | 3 | error_message=New error message |
"""
message = error_message
number = int(number)
all_screen = self._read_all_screen()
if ignore_case:
txt = str(txt).lower()
all_screen = str(all_screen).lower()
number_of_times = all_screen.count(txt)
if number_of_times != number:
if message is None:
message = 'The string "' + txt + '" was not found "' + str(number) + '" times, it appears "' \
+ str(number_of_times) + '" times'
raise Exception(message)
logger.info('The string "' + txt + '" was found "' + str(number) + '" times')
示例5: take_a_screenshot
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def take_a_screenshot(self):
'''Takes a screenshot of the screen.
This keyword is run on failure if it is not overwritten when
`importing` the library.
Screenshots are saved to the current working directory or in the
``screenshot_folder`` if such is defined during `importing`.
The file name for the screenshot is the current suite name with a
running integer appended. If this keyword is used outside of Robot
Framework execution, file name is this library's name with running
integer appended.
'''
target_dir = self.screenshot_folder if self.screenshot_folder else ''
if not isinstance(target_dir, str):
raise ScreenshotFolderException('Screenshot folder is invalid: '
'"%s"' % target_dir)
path = self._make_up_filename()
path = abspath(path_join(target_dir, path))
LOGGER.info('Screenshot taken: {0}<br/><img src="{0}" '
'width="100%" />'.format(path), html=True)
ag.screenshot(path)
示例6: _click_to_the_direction_of
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def _click_to_the_direction_of(self, direction, location, offset,
clicks, button, interval):
x, y = self._get_location(direction, location, offset)
try:
clicks = int(clicks)
except ValueError:
raise MouseException('Invalid argument "%s" for `clicks`')
if button not in ['left', 'middle', 'right']:
raise MouseException('Invalid button "%s" for `button`')
try:
interval = float(interval)
except ValueError:
raise MouseException('Invalid argument "%s" for `interval`')
LOGGER.info('Clicking %d time(s) at (%d, %d) with '
'%s mouse button at interval %f' % (clicks, x, y,
button, interval))
ag.click(x, y, clicks=clicks, button=button, interval=interval)
示例7: take_desktop_screenshot
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def take_desktop_screenshot(self):
"""Takes a screenshot of the whole desktop and inserts screenshot link to log file.
Returns path to the screenshot file.
"""
filepath = self._get_screenshot_path("whitelib_screenshot_{index}.png")
directory = os.path.dirname(filepath)
if not os.path.exists(directory):
os.makedirs(directory)
logger.info(get_link_path(filepath, self._log_directory))
logger.info(
'</td></tr><tr><td colspan="3">'
'<a href="{src}"><img src="{src}" width="800px"></a>'.format(
src=get_link_path(filepath, self._log_directory)
),
html=True,
)
bmp = Desktop.CaptureScreenshot()
bmp.Save(filepath, ImageFormat.Png)
return filepath
示例8: start_virtual_display
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def start_virtual_display(self, width=1440, height=900,
colordepth=24, **kwargs):
"""Starts virtual display which will be
destroyed after test execution will be end
*Arguments:*
- width: a width to be set in pixels
- height: a height to be set in pixels
- color_depth: a color depth to be used
- kwargs: extra parameters
*Example:*
| Start Virtual Display |
| Start Virtual Display | 1920 | 1080 |
| Start Virtual Display | ${1920} | ${1080} | ${16} |
"""
if self._display is None:
logger.info("Using virtual display: '{0}x{1}x{2}'".format(
width, height, colordepth))
self._display = Xvfb(int(width), int(height),
int(colordepth), **kwargs)
self._display.start()
atexit.register(self._display.stop)
示例9: log_json
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def log_json(json, header="", also_console=True, sort_keys=False):
json = dumps(
json,
ensure_ascii=False,
indent=4,
separators=(",", ": "),
sort_keys=sort_keys,
)
logger.info("{}\n{}".format(header, json)) # no coloring for log.html
if also_console:
json_data = highlight(
json, lexers.JsonLexer(), formatters.TerminalFormatter()
)
logger.console("{}\n{}".format(header, json_data), newline=False)
return json
示例10: log_page_object_keywords
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def log_page_object_keywords(self):
"""Logs page objects and their keywords for all page objects
which have been imported into the current suite.
"""
for key in sorted(self.registry.keys()):
pobj = self.registry[key]
keywords = get_keyword_names(pobj)
logger.info("{}: {}".format(key, ", ".join(keywords)))
示例11: _make_up_filename
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def _make_up_filename(self):
try:
path = BuiltIn().get_variable_value('${SUITE NAME}')
path = '%s-screenshot' % path.replace(' ', '')
except RobotNotRunningError:
LOGGER.info('Could not get suite name, using '
'default naming scheme')
path = 'ImageHorizon-screenshot'
path = '%s-%d.png' % (path, self.screenshot_counter)
self.screenshot_counter += 1
return path
示例12: click_image
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def click_image(self, reference_image):
'''Finds the reference image on screen and clicks it once.
``reference_image`` is automatically normalized as described in the
`Reference image names`.
'''
center_location = self.locate(reference_image)
LOGGER.info('Clicking image "%s" in position %s' % (reference_image,
center_location))
ag.click(center_location)
return center_location
示例13: wait_for
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def wait_for(self, reference_image, timeout=10):
'''Tries to locate given image from the screen for given time.
Fail if the image is not found on the screen after ``timeout`` has
expired.
See `Reference image names` for documentation for ``reference_image``.
``timeout`` is given in seconds.
Returns Python tuple ``(x, y)`` of the coordinates.
'''
stop_time = time() + int(timeout)
location = None
with self._suppress_keyword_on_failure():
while time() < stop_time:
try:
location = self._locate(reference_image, log_it=False)
break
except ImageNotFoundException:
pass
if location is None:
self._run_on_failure()
raise ImageNotFoundException(self.__normalize(reference_image))
LOGGER.info('Image "%s" found at %r' % (reference_image, location))
return location
示例14: _info
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def _info(self, message):
if self._log_level in self.LOG_LEVEL_INFO:
logger.info(message)
示例15: _html
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import info [as 别名]
def _html(self, message):
if self._log_level in self.LOG_LEVEL_INFO:
logger.info(message, True, False)