Forum Discussion

Kanika's avatar
Kanika
Contributor
10 years ago

How to capture error screen if suddenly error occurs in an application while running TestComplete?

For Example - I have  to fill a questionnaire having 10 questions and out of which one question also contains image which by chance fail to load during loading of questionnaire questionnaire. How can I check this scenario and can capture error image?

  • william_roe's avatar
    william_roe
    Super Contributor

    Kanika wrote:

    For Example - I have  to fill a questionnaire having 10 questions and out of which one question also contains image which by chance fail to load during loading of questionnaire questionnaire. How can I check this scenario and can capture error image?


    Try:

     

    Log.Picture (obj.Picture(), "image");

     

    Of course obj needs to be set. I've used this while writing code to find an object with XPath:

     

    var obj = page.FindChildByXPath("//table[@id='grdCribPrivileges_DXMainTable']//td[text()='" + Privileges[i] + "']/parent::node()/td[@onclick]", true);

    • Kanika's avatar
      Kanika
      Contributor

      Thanks for the reply. When I am running my script, "Has Picture" column capturing pictures of all actions performed . No matter whether it is pass or fail . I think Log. Picture() also post picture in "Has Picture" column. I dont want pictures of pass scenario and only want pictures of failed scenario . It would be better if you able to tell me how to handle failed scenario (effective way or good practice ) also with there screens.

    • Kanika's avatar
      Kanika
      Contributor

      I think the best way of error handling is :

       

      if obj.Exists then

       .......

       .......

      else 

         str = Log.Picture(page.Picture(), "User object not found")

      end if

       

      Please suggest if there is some other way apart from this.