From e6cf36f3ff07f713969ab1818b95b43b395461eb Mon Sep 17 00:00:00 2001 From: Dave Amies Date: Fri, 25 Feb 2022 22:02:19 +1000 Subject: [PATCH 1/2] Fix for Issue #28 relative path for screenshots --- src/ImageHorizonLibrary/recognition/_screenshot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ImageHorizonLibrary/recognition/_screenshot.py b/src/ImageHorizonLibrary/recognition/_screenshot.py index 3738b67..d65b49c 100644 --- a/src/ImageHorizonLibrary/recognition/_screenshot.py +++ b/src/ImageHorizonLibrary/recognition/_screenshot.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from os.path import abspath, join as path_join +from os.path import abspath, relpath, join as path_join from random import choice from string import ascii_lowercase @@ -43,6 +43,8 @@ def take_a_screenshot(self): '"%s"' % target_dir) path = self._make_up_filename() path = abspath(path_join(target_dir, path)) + logpath = BuiltIn().get_variable_value('${OUTPUT DIR}') + relativepath = relpath(path, start=logpath).replace(r'\', r'/') LOGGER.info('Screenshot taken: {0}
'.format(path), html=True) + 'width="100%" />'.format(relativepath), html=True) ag.screenshot(path) From 85cd76ae23f88d291604ae26b779b57966b4ccef Mon Sep 17 00:00:00 2001 From: Dave Amies Date: Fri, 25 Feb 2022 22:24:00 +1000 Subject: [PATCH 2/2] Fix for Issue #28 relative path for screenshots 2 After testing needed a minor change, not sure why raw string didn't work, but escaped string does. --- src/ImageHorizonLibrary/recognition/_screenshot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageHorizonLibrary/recognition/_screenshot.py b/src/ImageHorizonLibrary/recognition/_screenshot.py index d65b49c..90e125c 100644 --- a/src/ImageHorizonLibrary/recognition/_screenshot.py +++ b/src/ImageHorizonLibrary/recognition/_screenshot.py @@ -44,7 +44,7 @@ def take_a_screenshot(self): path = self._make_up_filename() path = abspath(path_join(target_dir, path)) logpath = BuiltIn().get_variable_value('${OUTPUT DIR}') - relativepath = relpath(path, start=logpath).replace(r'\', r'/') + relativepath = relpath(path, start=logpath).replace('\\', '\/') LOGGER.info('Screenshot taken: {0}
'.format(relativepath), html=True) ag.screenshot(path)