Closed Bug 762126 Opened 12 years ago Closed 11 years ago

Allow to specify the screenshot path via the persisted object (CLI option)

Categories

(Testing Graveyard :: Mozmill, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: whimboo, Assigned: davehunt)

References

Details

(Whiteboard: [mozmill-2.0+])

Attachments

(1 file, 4 obsolete files)

Right now we save the screenshots to the mozmill-screenshots subfolder under temporary files. That's not always wanted and for Mozmill Crowd we want to store them in the same folder as the user has specified.

Therefore in our automation scripts we are using the persisted object and a CLI option (--screenshot-path). See bug 614972.

Now that the screenshot module is part of Mozmill we should do the same here.
Whiteboard: [mozmill-2.0?] → [mozmill-2.0+]
QA Contact: dave.hunt
Assignee: nobody → dave.hunt
QA Contact: dave.hunt
Pointer to Github pull-request
Comment on attachment 647370 [details]
Pointer to Github pull request: https://github.com/mozilla/mozmill/pull/81

This created the file in the appropriate directory, however I was unable to open the image even if it was created in the temporary path location. There also seems to be some discrepancy with file types - a comment mentions PNG but the file name is JPG.
Attachment #647370 - Flags: review?(jhammel)
We should probably add the argument to mozmill.create as well
(In reply to Jeff Hammel [:jhammel] from comment #3)
> We should probably add the argument to mozmill.create as well

:davehunt, do you mind fixing this first?  Other than that, the patch looks mostly fine.  Should probably be more explicit in the CLI help that the path == a directory

+            path = os.path.abspath(screenshot_path)
+            if not os.path.isdir(path):
+                os.makedirs(path)
+            self.persisted['screenshotPath'] = screenshot_path

I would assume that file.initWithPath(frame.persisted['screenshotPath']); works with relative paths?  

So if you don't pass the screenshot_path, how does one know where the screenshots go?  Should this be added to persisted from the JS side?  Or, alternately, should python create the directory?  Something should print out where the screenshots are.  I'm not sure what the present status is
(In reply to Jeff Hammel [:jhammel] from comment #4)
> I would assume that file.initWithPath(frame.persisted['screenshotPath']);
> works with relative paths?  

I don't think so. We should make it an absolute path before assigning it to persisted.

> So if you don't pass the screenshot_path, how does one know where the
> screenshots go?  Should this be added to persisted from the JS side?  Or,
> alternately, should python create the directory?  Something should print out
> where the screenshots are.  I'm not sure what the present status is

If no path gets specified we should fallback to the temp folder, which we currently use to save screenshots to. Well, it's a subfolder under temp. But that logic could be part of the python code and would make the JS side cleaner.
I'm sorry I didn't address this sooner, this got lost in my inbox

(In reply to Henrik Skupin (:whimboo) from comment #5)
> (In reply to Jeff Hammel [:jhammel] from comment #4)
> > I would assume that file.initWithPath(frame.persisted['screenshotPath']);
> > works with relative paths?  
> 
> I don't think so. We should make it an absolute path before assigning it to
> persisted.
> 
> > So if you don't pass the screenshot_path, how does one know where the
> > screenshots go?  Should this be added to persisted from the JS side?  Or,
> > alternately, should python create the directory?  Something should print out
> > where the screenshots are.  I'm not sure what the present status is
> 
> If no path gets specified we should fallback to the temp folder, which we
> currently use to save screenshots to. Well, it's a subfolder under temp. But
> that logic could be part of the python code and would make the JS side
> cleaner.

I agree on both points.  r-ing for now until these points are addressed.  We should
- specify the absolute path in all cases
- and specify the screenshot path from the python side
- (and preferably print out the path if any screenshots are saved)

I wouldn't mind if the directory creation on non-existence happens on the JS side, saving a tempdir if there are no screenshots.
Attachment #647370 - Flags: review?(jhammel) → review-
Pointer to Github pull-request
Attachment #662984 - Flags: review?(jhammel)
Attachment #647370 - Attachment is obsolete: true
Blocks: 795264
Comment on attachment 662984 [details]
Pointer to Github pull request: https://github.com/mozilla/mozmill/pull/88

This wfm.  Sorry, this got lost in my review queue for awhile
Attachment #662984 - Flags: review?(jhammel) → review+
Dave, there is one thing I would like to see addressed. Looking into the future it would probably helpful to have a screenshot property on the persisted object which can hold more than only the path, e.g. the screenshot format.

So would you mind changing the following?

< self.persisted['screenshotPath'] = screenshot_path
> self.persisted['screenshot']['path'] = screenshot_path

With it we would be totally flexible for upcoming additions and we wouldn't have to change our dashboard once we support screenshots.
Comment on attachment 662984 [details]
Pointer to Github pull request: https://github.com/mozilla/mozmill/pull/88

Pull request updated as suggested in comment 9.
Attachment #662984 - Flags: review+ → review?(hskupin)
Comment on attachment 662984 [details]
Pointer to Github pull request: https://github.com/mozilla/mozmill/pull/88

Looks great now for the patch, but I really would like to see a test for this feature too.
Attachment #662984 - Flags: review?(hskupin) → review+
Comment on attachment 662984 [details]
Pointer to Github pull request: https://github.com/mozilla/mozmill/pull/88

Requesting feedback for my first mutt tests.
Attachment #662984 - Flags: review+ → feedback?(hskupin)
Comment on attachment 662984 [details]
Pointer to Github pull request: https://github.com/mozilla/mozmill/pull/88

Good start Dave! It looks fine. I have made some more detailed comments on the pull.
Attachment #662984 - Flags: feedback?(hskupin) → feedback+
Comment on attachment 662984 [details]
Pointer to Github pull request: https://github.com/mozilla/mozmill/pull/88

Updated pull request based on feedback
Attachment #662984 - Flags: feedback+ → feedback?(hskupin)
Comment on attachment 662984 [details]
Pointer to Github pull request: https://github.com/mozilla/mozmill/pull/88

Looks good. I have made comments on the pull request. I wonder if we should move the patch over here for the next iteration.
Attachment #662984 - Flags: feedback?(hskupin) → feedback+
Moved to Bugzilla as suggested. Closed outstanding pull request in github.
Attachment #662984 - Attachment is obsolete: true
Attachment #714343 - Flags: review?(hskupin)
Comment on attachment 714343 [details] [diff] [review]
Allow specifying screenshot path. v2.0

Review of attachment 714343 [details] [diff] [review]:
-----------------------------------------------------------------

Some comments to address. Otherwise it looks good.

::: mozmill/mozmill/__init__.py
@@ +680,5 @@
>                           help="Specify an event handler given a file PATH "
>                                "and the CLASS in the file")
> +        group.add_option('--screenshots-path',
> +                         dest='screenshots_path',
> +                         default=None,

nit: please kill this line. It's not necessary.

::: mutt/mutt/tests/python/testscreenshotpath.py
@@ +16,5 @@
> +          controller = mozmill.getBrowserController();
> +        }
> +
> +        let test = function() {
> +          var backButton = new elementslib.ID(controller.window.document, 'back-button');

Please use mozElement to retrieve elements in Mozmill 2.

@@ +41,5 @@
> +        assert len(screenshots) == 1
> +        screenshot = os.path.join(screenshots_path, '%s.jpg' % screenshot_name)
> +        assert screenshots[0]['filename'] == screenshot
> +        assert os.path.isfile(screenshot)
> +        shutil.rmtree(screenshots_path)

Mind adding this also to tearDown? So we can ensure to delete the folder if the test fails due to whatever reasons.
Attachment #714343 - Flags: review?(hskupin) → review+
Updated according to review feedback.
Attachment #714343 - Attachment is obsolete: true
Attachment #721203 - Flags: review?(hskupin)
Comment on attachment 721203 [details] [diff] [review]
Allow specifying screenshot path. v2.1

Review of attachment 721203 [details] [diff] [review]:
-----------------------------------------------------------------

One thing to fix. With it my r+ and you can land it.

::: mutt/mutt/tests/python/testscreenshotpath.py
@@ +16,5 @@
> +          controller = mozmill.getBrowserController();
> +        }
> +
> +        let test = function() {
> +          var backButton = new mozelement.ID(controller.window.document, 'back-button');

Can you please do it like the MDN page tells?

https://developer.mozilla.org/en-US/docs/Mozmill/Finding_Mozmill_Elements
Attachment #721203 - Flags: review?(hskupin) → review+
Comment on attachment 727627 [details] [diff] [review]
Allow specifying screenshot path. v2.2

Carrying r+ from previous review.
Attachment #727627 - Flags: review+
Landed as:
https://github.com/mozilla/mozmill/commit/e9054305d777eedae37fa0abc2426e50fb2b58a1
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Product: Testing → Testing Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: