33
44from Selenium2Library import utils
55from keywordgroup import KeywordGroup
6- from robot .libraries .BuiltIn import RobotNotRunningError
76
87
98class _ScreenshotKeywords (KeywordGroup ):
@@ -18,12 +17,13 @@ def __init__(self):
1817 def set_screenshot_directory (self , path , persist = False ):
1918 """Sets the root output directory for captured screenshots.
2019
21- ``path`` argument specifies the location to where the screenshots should
20+ ``path`` argument specifies the absolute path where the screenshots should
2221 be written to. If the specified ``path`` does not exist, it will be created.
2322 Setting ``persist`` specifies that the given ``path`` should
2423 be used for the rest of the test execution, otherwise the path will be restored
2524 at the end of the currently executing scope.
2625 """
26+ path = os .path .abspath (path )
2727 self ._create_directory (path )
2828 if persist is False :
2929 self ._screenshot_path_stack .append (self .screenshot_root_directory )
@@ -80,12 +80,7 @@ def _get_screenshot_directory(self):
8080 return self .screenshot_root_directory
8181
8282 # Otherwise use RF's log directory
83- try :
84- return self ._get_log_dir ()
85-
86- # Unless robotframework isn't running, then use working directory
87- except RobotNotRunningError :
88- return os .getcwd ()
83+ return self ._get_log_dir ()
8984
9085 # should only be called by set_screenshot_directory
9186 def _restore_screenshot_directory (self ):
@@ -97,7 +92,9 @@ def _get_screenshot_paths(self, filename):
9792 filename = 'selenium-screenshot-%d.png' % self ._screenshot_index
9893 else :
9994 filename = filename .replace ('/' , os .sep )
95+
10096 screenshotDir = self ._get_screenshot_directory ()
97+ logDir = self ._get_log_dir ()
10198 path = os .path .join (screenshotDir , filename )
102- link = robot .utils .get_link_path (path , screenshotDir )
99+ link = robot .utils .get_link_path (path , logDir )
103100 return path , link
0 commit comments