Поэтому мой код выглядит примерно так
Код: Выделить всё
class RobotListenerV2:
ROBOT_LISTENER_API_VERSION = 2
ROBOT_LIBRARY_SCOPE = "GLOBAL"
def end_keyword(self, name, attrs):
# print('-------------------------------------------------------')
# print('END keyword NAME => {} and ATTRIBUTES => {}'.format(name, attrs))
#print('END keyword NAME => {} and ATTRIBUTES => {}'.format(name, attrs['status']))
# print('-------------------------------------------------------')
if attrs['status'] == 'FAIL' and attrs['status'] != 'NOT RUN':
current_directory = os.getcwd()
try:
image_folder = ''
variables = BuiltIn().get_variables()
for k, v in variables.items():
if 'OUTPUT_DIR' in k:
image_folder = v
time_ = round(time.time() * 1000)
if ' ' in image_folder:
image_folder = image_folder.replace(' ','')
if not os.path.exists(os.path.join(current_directory, image_folder)):
os.makedirs(os.path.join(current_directory, image_folder))
image_name = self.full_screen(image_folder)
url = self.get_web_driver_instance().current_url
data_uri = base64.b64encode(open(image_name, 'rb').read()).decode('utf-8')
logger.info(
''
'[url=data:image/png;base64,{data_uri}]'
''
'[/url]',
html=True,
)
logger.info('[url={}]"{}"[/url]'.format(url, url), html=True)
logger.info('Keyword Name : {} and attributes : {}'.format(name, attrs), html=True)
except Exception as ex:
print("We have Exception:", type(ex))
print("We have Exception:", repr(ex))
if hasattr(ex, 'message'):
print(ex.message)
else:
print(ex)
finally:
Есть идеи, как ограничить создание скриншотов для единственного неудачного ключевого слова?
Если вам нужна дополнительная информация, я приведу полный пример
Подробнее здесь: https://stackoverflow.com/questions/791 ... screenshot