Continuum
  1. Continuum
  2. CONTINUUM-2268

Continuum Webapp Tests Capture Screenshot for AbstractSeleniumTest.java

    Details

    • Type: Test Test
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.0 (Beta)
    • Component/s: Testing
    • Labels:
      None
    • Environment:
      Linux
    • Complexity:
      Intermediate
    • Patch Submitted:
      Yes
    • Number of attachments :
      2

      Description

      The attached patch includes the following changes:
      Changed continuum-webapp-tests/pom.xml selenium version from 0.9.2 to 1.0.1
      Added a captureEntirePageScreenshot to AbstractSeleniumTest.java
      Added a catch block for every failed assertion to do a screen capture and save them to target/screenshots directory
      Formatted the filename of the captured file as "methodName(className.java:lineNumber)-time.png"

      Additional Info:

      Maven version: 2.0.10
      Java version: 1.5.0_16
      OS name: "linux" version: "2.6.27-14-generic" arch: "i386" Family: "unix"

      Patch created at revision 785116.

      Build Results:
      Results :
      Tests run: 167, Failures: 0, Errors: 0, Skipped: 0

        Activity

        Hide
        Bernard Lago added a comment -

        Please disregard the first attachment and use CaptureScreenshotForAbstractSeleniumTest.patch
        Minor code changes were made to this new one.

        Additional Info:
        Patch created at revision 785468

        Results :

        Tests run: 167, Failures: 0, Errors: 0, Skipped: 0

        [INFO] [cargo:stop

        {execution: stop-container}

        ]
        [INFO] [install:install]
        [INFO] Installing /home/blago/Documents/apache/continuum/trunk/continuum-webapp-test/pom.xml to /home/blago/.m2/repository/org/apache/continuum/continuum-webapp-test/1.4.0-SNAPSHOT/continuum-webapp-test-1.4.0-SNAPSHOT.pom
        [INFO] ------------------------------------------------------------------------
        [INFO] BUILD SUCCESSFUL
        [INFO] ------------------------------------------------------------------------
        [INFO] Total time: 23 minutes 21 seconds
        [INFO] Finished at: Wed Jun 17 12:05:44 GMT+08:00 2009
        [INFO] Final Memory: 32M/113M
        [INFO] ------------------------------------------------------------------------

        Show
        Bernard Lago added a comment - Please disregard the first attachment and use CaptureScreenshotForAbstractSeleniumTest.patch Minor code changes were made to this new one. Additional Info: Patch created at revision 785468 Results : Tests run: 167, Failures: 0, Errors: 0, Skipped: 0 [INFO] [cargo:stop {execution: stop-container} ] [INFO] [install:install] [INFO] Installing /home/blago/Documents/apache/continuum/trunk/continuum-webapp-test/pom.xml to /home/blago/.m2/repository/org/apache/continuum/continuum-webapp-test/1.4.0-SNAPSHOT/continuum-webapp-test-1.4.0-SNAPSHOT.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 23 minutes 21 seconds [INFO] Finished at: Wed Jun 17 12:05:44 GMT+08:00 2009 [INFO] Final Memory: 32M/113M [INFO] ------------------------------------------------------------------------
        Hide
        Wendy Smoak added a comment -

        Thanks, Bernard, this is really neat! Applied on trunk r785845

        I'm leaving the issue open for documentation, src/site/apt/index.apt (or a another page if that gets too long) needs to talk about this.

        Show
        Wendy Smoak added a comment - Thanks, Bernard, this is really neat! Applied on trunk r785845 I'm leaving the issue open for documentation, src/site/apt/index.apt (or a another page if that gets too long) needs to talk about this.
        Hide
        Jose Morales Martinez added a comment -

        It's good idea.

        I am searching information about logs inTestNG and I think we can replace try/catch in AbstractSeleniumTest for TestNG listeners [1] and then we take screenshot. What do you think about it?

        [1] http://testng.org/doc/documentation-main.html#logging-listeners.

        Show
        Jose Morales Martinez added a comment - It's good idea. I am searching information about logs inTestNG and I think we can replace try/catch in AbstractSeleniumTest for TestNG listeners [1] and then we take screenshot. What do you think about it? [1] http://testng.org/doc/documentation-main.html#logging-listeners .
        Hide
        Jose Morales Martinez added a comment -

        I will change filename format because use ':' and this character is not allowed in filename for Windows.

        Show
        Jose Morales Martinez added a comment - I will change filename format because use ':' and this character is not allowed in filename for Windows.
        Hide
        Bernard Lago added a comment -

        Thanks for pointing out the use of ":"
        I haven't tried this on a windows box. Please do the necessary changes. Thanks again!
        Still reading about the TestNG Listeners. I will try it out and see if it will work.

        Show
        Bernard Lago added a comment - Thanks for pointing out the use of ":" I haven't tried this on a windows box. Please do the necessary changes. Thanks again! Still reading about the TestNG Listeners. I will try it out and see if it will work.
        Hide
        Bernard Lago added a comment - - edited

        Jose,

        I tried the example from the link you posted about TestNG Listeners.
        I created a class that subclasses TestListenerAdapter and created a method that will be called for every test failure. I also modified pom.xml's maven-surefire-plugin to use the new Listener class.
        For the said method, I am having issues creating the selenium object that will call the captureEntirePageScreenshot method. If I create a new selenium object, then I will have to pass another set of parameters. (url, browser, etc) and it would be like calling the open() method of AbstractSeleniumTest class again.
        It seems complicated to use this inside the Listener class. A possible workaround is to write a new capture screenshot method inside the Listener class and not use selenium's capture method. (btw, I prefer using selenium's capture method)
        Maybe you can suggest how to implement this using Listeners.

        Bernard

        Show
        Bernard Lago added a comment - - edited Jose, I tried the example from the link you posted about TestNG Listeners. I created a class that subclasses TestListenerAdapter and created a method that will be called for every test failure. I also modified pom.xml's maven-surefire-plugin to use the new Listener class. For the said method, I am having issues creating the selenium object that will call the captureEntirePageScreenshot method. If I create a new selenium object, then I will have to pass another set of parameters. (url, browser, etc) and it would be like calling the open() method of AbstractSeleniumTest class again. It seems complicated to use this inside the Listener class. A possible workaround is to write a new capture screenshot method inside the Listener class and not use selenium's capture method. (btw, I prefer using selenium's capture method) Maybe you can suggest how to implement this using Listeners. Bernard
        Hide
        Jose Morales Martinez added a comment -

        Fixed in 787880r.

        I declare listener CaptureScreenShotsListener in pom and move capture process to this listener. I delete try/catch from selenium class.

        I think this issue is finished.

        Thank Bernard.

        Show
        Jose Morales Martinez added a comment - Fixed in 787880r. I declare listener CaptureScreenShotsListener in pom and move capture process to this listener. I delete try/catch from selenium class. I think this issue is finished. Thank Bernard.

          People

          • Assignee:
            Jose Morales Martinez
            Reporter:
            Bernard Lago
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: