Forum Discussion

ArmandsBruns's avatar
ArmandsBruns
Frequent Contributor
12 years ago

Function (Auto-Generating Screenshots -> click)

Hi,



Maybe someone knows, how to "Auto-Generating Screenshots During Test Running" in my script.



Regards

Armands

9 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Armands,


     


    To enable posting images when executing tests, enable the Use Test Visualizer during test run option.


     

  • ArmandsBruns's avatar
    ArmandsBruns
    Frequent Contributor
    Hi Tanya,



    Thanks for your reply.



    I mean that after each "click" would be possible to save a picture in my function ?



    ------------------------------------------------

    Function IfObjectExists(location, typeID, name)

     

      IfObjectExists = False

     

      Sys.Refresh()

      location.RefreshMappingInfo

     

      Do

        counter = counter + 1



          Sys.Refresh()

          location.RefreshMappingInfo

          

        If(location.FindChild( typeID, name,30).Exists <> Empty ) Then

          IfObjectExists = True

          log.Message("Find this object - '"+typeID+"', '"+name+"' - and click!")

          

          object = location.FindAllChildren(typeID, name, 20000, True)



          For i = 0 to UBound(object)

            If object(i).Exists and object(i).Visible=True Then

            object(i).Click



            Call Save_Picture(name)



            log.message("click to object")

          Next

       

          Log.Message "Find: " & (UBound(object) + 1)

          Call location.Wait



        Else

          IfObjectExists = False

          aqUtils.Delay(2000)

          Sys.Refresh()

          location.RefreshMappingInfo    

          log.Message ("Doesn't find this objects: '"+typeID+"', '"+name+"'")

        End If



      Loop Until IfObjectExists = True or counter > 25



    End Function

    ------------------------------------------------



    Sub Save_Picture(name)



      Set pict = Sys.Desktop.Picture()

      Call Log.Picture(pict, name)



    End Sub



    ------------------------------------------------



    Besr Regards



    Armands
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Armands,


     


    I don't see what is wrong with your function - a picture of your desktop is posted to the log after you click an object. What is the issue?


     

  • ArmandsBruns's avatar
    ArmandsBruns
    Frequent Contributor


    Hi Tanya,



    If the form is open very quickly after
    click then I don't see the button in the saved picture which was pressed.



    Regards

    Armands


     


  • Hi Armands,



    Depending on what's the picture needed to, you could take the screenshot just after making sure that the object exists and is visible, and just before doing the click.



    If you need to take a screenshot of the exact moment when you click... I don't really know how!



    Hope it helped
  • ArmandsBruns's avatar
    ArmandsBruns
    Frequent Contributor
    Hi Javier,




    Exactly, I need to take a screenshot of the exact moment when you click (It would be perfect if it could be done)



    Regards

    Armands


     

  • Hi Armands,



    I don't really know why it does not take a screenshot when you click...



    Make sure that you have events enabled and visible on your log, so I haven't seen any project or TC option to configure that.



    Bye!
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Armands,


     


    Let me quote the Project Properties - Visualizer Options article I gave you:


    >>


    Use Test Visualizer during test run - If this option is enabled, Test Visualizer captures screenshots for all user actions during the test run.


    <<

  • ArmandsBruns's avatar
    ArmandsBruns
    Frequent Contributor
    The most interesting thing is that  "My Project" -> Project Properties -> Visualizer Options - > is enabled !



    But after test execution with TestExecute the screenshots is created only for error messages but not for all user actions during the test?



    Note: TesExecute has separate license (client side)



    Regards

    Armands