Skip to content

Added screenshot_root_directory#443

Merged
just-be-dev merged 9 commits into
masterfrom
default-screenshot-dir
Jul 22, 2015
Merged

Added screenshot_root_directory#443
just-be-dev merged 9 commits into
masterfrom
default-screenshot-dir

Conversation

@just-be-dev

Copy link
Copy Markdown
Contributor

This enhancement is to better support PageObjects as discussed here.

These changes are not necessarily final and reviews are welcome.

This PR would essentially provides a new argument for S2L called screenshot_root_directory which can be provided to set the default root directory that screenshots will be stored in. Subdirectories should still be managed by the relevant keywords.

By default the screenshot_root_directory argument is set to None and will use RF's log directory as the root directory for screenshots. If one is trying to run a screenshot keyword while RF isn't running and fails to provide screenshot_root_directory then the current working directory will be used instead.

Pre-merge checklist

  • Import RobotNotRunningError
  • Add a test to use screenshot_root_directory
  • Add Documentation
  • Update changelog

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. RobotNotRunningError doesn't seem to be imported.
  2. Why not just return . instead of os.getcwd? In most cases the end result is the same.
  3. I was thinking screenshot_root_directory would be returned only if Robot isn't running, but always returning it if defined may be a useful feature in general.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Whoops, nice catch. I haven't written a test for this yet, but I certainly will before its merged in.
  2. Simply because I like to be explicit.
  3. If we're going to add it, we may as well make it available to everyone. I actually added it as an argument into the S2L constructor so it'd be a newly documented feature.

@just-be-dev

Copy link
Copy Markdown
Contributor Author

@pekkaklarck, do you have any advice on testing this feature? Is there a way to "unload" a library?

@pekkaklarck

Copy link
Copy Markdown
Member

Would Reload Library keyword, available since RF 2.9 alpha 2, work in this case? See robotframework/robotframework#293 and http://robotframework.org/robotframework/2.9rc1/libraries/BuiltIn.html#Reload%20Library for details.

@pekkaklarck

Copy link
Copy Markdown
Member

Oooops, sorry for accidentally closing this. Having close and comment buttons next to each others is super annoying.

@pekkaklarck pekkaklarck reopened this Jul 16, 2015
@just-be-dev

Copy link
Copy Markdown
Contributor Author

I don't think so... I may just create a keyword to change the screenshot directory from within the test... Though that could lead to issues I suppose...

Hmmm.. I'll think on it.

@pekkaklarck

Copy link
Copy Markdown
Member

You should actually be able to import the library with different arguments. You just need to use the WITH NAME syntax to give custom name to the libraries you import. You'll also get a conflict with each keyword, so you need to use the LibName.Keyword Name syntax with each keyword or use Set Library Search Order to make one of the imported libraries the default library.

Having a keyword to change the screenshot directory might still be a good idea, though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's likely that this could cause an issue. If the same scope sets two screenshot paths then only the first would be popped off when the scope exited. That could cause an issue where the wrong path is used for other scopes...

EDIT: I've decided to go ahead and use what I've got. Being that this is a private part of the API I can solidify this in the next release.

just-be-dev added a commit that referenced this pull request Jul 22, 2015
Added screenshot_root_directory argument and set_screenshot_directory keyword
@just-be-dev just-be-dev merged commit d88545d into master Jul 22, 2015
@just-be-dev just-be-dev deleted the default-screenshot-dir branch July 24, 2015 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants