Closed spooning closed 9 years ago
Originally submitted to Google Code by spielman... on 5 Oct 2010
Hi Marcin,
If a test fails, you can log a screenshot:
Run Keyword If Test Failed Capture Screenshot
(or Capture Page Screenshot), see [1] and [2].
Put that into the Test Teardown like:
* Settings * Test Teardown Teardown Selenium
* Keywords * Teardown Selenium Run Keyword If Test Failed Log Screenshot
Log Screenshot
Run Keyword If '${BROWSER_PROFILE}' != '_iexplore' and '${BROWSER_PROFILE}' != 'ie' and '${BROWSER_PROFILE}' != 'internetexplorer' and '${BROWSER_PROFILE}' != '_iehta' and '${BROWSER_PROFILE}' != 'iehta' Capture Page Screenshot
So that would cover all cases where the test fails.
About highlighting the "object under test", I assume you mean something like draw a green border around a certain element in the page? Do you have exact ideas or an example of what you would like to do?
[1] http://robotframework-seleniumlibrary.googlecode.com/hg/doc/SeleniumLibrary.html?r=2.4#Capture%20Screenshot
[2] http://robotframework-seleniumlibrary.googlecode.com/hg/doc/SeleniumLibrary.html?r=2.4#Capture%20Page%20Screenshot
Originally submitted to Google Code by Marcin.Koperski on 5 Oct 2010
Hi Robert
My idea was to have similar look as we get using Selenium IDE, using button Find which highlights Target, maybe its possible to execute this command (or functionality ) and at the same time make screen shot.
Your solution is good, but it will give only screen shot on the finish of the test, sometimes you want to proceed even when validation failed but functional step are working properly.
Originally submitted to Google Code by @pekkaklarck on 21 Oct 2010
This is a very often requested feature. Ought to be relatively easy to implement with some metaclass magic so that existing methods don't need to be touched.
Should we take screenshots always when a keyword fails automatically or should this be configurable? If this is configurable, should the default be on or off? Would it be enough to have an import parameter or should we have a keyword instead (or in addition)?
Originally submitted to Google Code by Marcin.Koperski on 21 Oct 2010
I think it should be configurable (default on) using import parameter. The same solution would be nice to work with highlighting Target.
Originally submitted to Google Code by @pekkaklarck on 22 Oct 2010
Highlighting target should be a separate issue. How to implement that depends on how Selenium RC supports highlighting.
Originally submitted to Google Code by spielman... on 24 Oct 2010
I remember that we had major issues with screenshots in Internet Explorer, which effectively forced us to build a smart keyword that only takes a screenshot if no IE browser profile is being used for the test run. I'll investigate this, because even if taking the screenshot is configurable, it would probably not be desirable to switch screenshots on and off by ugly hacks if you run tests across multiple browsers.
Originally submitted to Google Code by @pekkaklarck on 14 Nov 2010
I've been investigating this and already got the basic functionality working. There's currently autoscreenshot.py file in the code base which implements a metaclass that automatically wraps keywords so that a screenshot is taken upon failure. This code isn't yet used, though.
Originally submitted to Google Code by @yanne on 15 Nov 2010
Since there are some differences in how taking screenshots works on different platforms, we decided to implement this so that it is possible to configure a keyword which is executed when another SeleniumLibrary keyword fails.
The keyword to be run can be given on library init or using a separate keyword-
Originally submitted to Google Code by @yanne on 15 Nov 2010
Implemented and added tests for the functionality described in comment 9 in revision d4feacc481f5.
The keyword that changes the keyword that is executed on failure is called Run On Failure
.
Documentation is still missing.
Originally submitted to Google Code by @yanne on 15 Nov 2010
Added some docs in revision d524080e96d5
Originally submitted to Google Code by @yanne on 15 Nov 2010
Added some docs in revision d524080e96d5
Originally submitted to Google Code by @pekkaklarck on 15 Nov 2010
I enhanced the docs in revision 3c2e1443ee. Janne, could you do the final review and close this one if everything looks good? Comments from others are obviously highly welcome too.
Originally submitted to Google Code by @yanne on 15 Nov 2010
Added one more example in revision ab1c024223ea
I consider this now done.
Originally submitted to Google Code by Marcin.Koperski on 15 Nov 2010
I think this solution is useful, not only for selenium test, because often if something brakes there is need to make additional steps
Originally submitted to Google Code by @pekkaklarck on 16 Nov 2010
Notice that this feature only works with Selenium. Generally you should use teardowns if you need to do actions in case of failures.
Originally submitted to Google Code by spielman... on 16 Nov 2010
This issue was updated by revision 95cc7d834c.
I fixed a mini-typo in the docs. Looks good otherwise.
Originally submitted to Google Code by spielman... on 16 Nov 2010
This issue was updated by revision d43b5fe19f.
I fixed another mini-typo in the docs. =)
Originally submitted to Google Code by jollych... on 28 Nov 2010
java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
Selenium RC server v2.0 a7 and selenium library 2.5 ;Robot Framework 2.5.4 (Python 2.6.1)
I would be good to have flag/option that will automatically make screen shot on Fail or other unexpected behavior. Also it would be good to highlight object which is under testing e.x. for example object which is provided as location for validation/input.