'Sets the root output directory for captured screenshots.
``path`` argument specifies the absolute path where the screenshots
should be written to. If the specified ``path`` does not exist,
it will be created. Setting ``persist`` specifies that the given
``path`` should be used for the rest of the test execution, otherwise
the path will be restored at the end of the currently executing scope.'

@keyword
def set_screenshot_directory(self, path, persist=False):

    path = os.path.abspath(path)
    self._create_directory(path)
    if (persist is False):
        self._screenshot_path_stack.append(self.screenshot_root_directory)
        events.on('scope_end', 'current', self._restore_screenshot_directory)
    self.screenshot_root_directory = path
