Skip to content

Set screenshot dir #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

marcdel
Copy link
Contributor

@marcdel marcdel commented Dec 28, 2017

Implements #196

WIP: line 66 of screenshot_test.exs is failing because I haven't found a way to get the ConnectionServer to pick up the updated :screenshot_dir config value since the supervisor has already started it. I've tried changing sessions, setting the env variable, stoping/starting the agent (my limited experience with OTP kept me from successfully going down this path, but I assume there's an easier way anyway).

If you know of a good way to update those config values, or have a better way of testing that, I'm definitely open to suggestions 😀

@@ -92,6 +92,7 @@ defmodule Hound.Helpers.Session do
* `:metadata` - The metadata to be included in the requests.
See `Hound.Metadata` for more information
* `:driver` - The additional capabilities to be passed directly to the webdriver.
* `:screenshot_dir` - Override the default directory that screenshots are saved to.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if this is actually true, or useful to document.

default_path = File.cwd!()

path1 = take_screenshot()
:timer.sleep(1000)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This adds an extra second to an already slow test, so I'm happy to rip this test out if you don't think it's necessary. I couldn't think of a better way to test this.

Copy link
Collaborator

@danhper danhper Jan 7, 2018

Choose a reason for hiding this comment

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

Tests speed is not that much of an issue yet, but is the granularity of the file name 1 second?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tuvistavie yeah, based on the way the filename is currently generated, it will only be unique down to the second.

https://github.com/marcdel/hound/blob/9a627eab709e5b852ee08eb2934e1fc37296128b/lib/hound/helpers/screenshot.ex#L33

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right, I completely forgot we were generating the name this way. Thanks.
We should probably improve this but it's not related to this PR, so let's see later.

setup do
screenshot_dir = "tmp/screenshots/"
Application.put_env(:hound, :screenshot_dir, screenshot_dir)
change_session_to(:with_opts, [screenshot_dir: screenshot_dir])
Copy link
Contributor Author

@marcdel marcdel Dec 28, 2017

Choose a reason for hiding this comment

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

These seem to happen too late in the application lifecycle. I'm not sure if there's an earlier event I can hook into?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This will normally be configured by config.exs anyway, so let's stick with what you have here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tuvistavie sorry, should have been more clear. Neither of the options (line 54 or 55 above) actually change the screenshot directory in the test so all it's currently testing is that the file name is generated in the same way.

This line actually fails right now:
https://github.com/marcdel/hound/blob/9a627eab709e5b852ee08eb2934e1fc37296128b/test/helpers/screenshot_test.exs#L66

@danhper
Copy link
Collaborator

danhper commented Jan 7, 2018

Thank you very much. I just left one comment, as soon as this is confirmed I think we can merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants