Forum Discussion

amalcodework's avatar
amalcodework
Occasional Contributor
6 years ago
Solved

'The object with the specified attributes does not exist.' error while checking for a CrystalReport

Hi All, 

Kindly help to resolve object checking errors on the VB Script. 

 

\I've been writing VB Script test cases for our windows application product. Below is the testing scenario that fails.

 

Our application provides some user activity reports to the administrators. The reports will be populated on Crystal Reports report viewer.

 

Test case and Scenario:

 

1. Run the report without making any selection.
2. If the report selection is not done, then a custom message box will be displayed.
3. Close the message box.
4. Make the selection and run the report.
5. If there is no data to be reported, then a default windows message box will be shown.
6. If the data is available, then it will be opened on Crystal Reports viewer.
7. Close the current report.
8. Repeat step #3 to #6 for the next report.
9. Repeat the same for almost 21 different reports.

 

On the VBScript, I have created this scenario as follows and it works fine except one error.

 

1. Check for the output.
2. If exist custom message box - then close it and make a report selection.
3. Else, check If exist crystal reports viewer. Then close the report and continue to next step.
4. Else, close the windows default message box assuming there is no data to be reported.

 

The issue happens and execution fails at stage #3 from the above. If there is no Crystal Reports viewer available then the whole checking is getting failed with the following error.

 

'The object with the specified attributes does not exist.'

 

Code from my script:

 

Function RunReport (rptOption)

  Set frmReportOptions = Aliases.cwConsole.frmReportOptions
  Set Rep = Sys.Process("cwConsole.exe").winformsObject("frmCrystalReport")
  Call frmReportOptions.gbReportType.cboReportTypes.ClickItem(rptOption)
  frmReportOptions.btnRunReport.ClickButton
  Sleep 6000
  err.clear
  on error resume Next
   
  If Not Aliases.cwConsole.dlgBrowseReporter.btnOK.Exists Then
    If Not Sys.Process("cwConsole.exe").winformsObject("frmCrystalReport").Exists Then
      Aliases.cwConsole.WinFormsObject("frmMsgBox_Specific").WinFormsObject("panel1").WinFormsObject("btnOK").ClickButton
      Aliases.cwConsole.frmReportOptions.WinFormsObject("gbSpecificURLs").WinFormsObject("lnkApplication").Click
      Aliases.cwConsole.WinFormsObject("frmSpecifiedUrls").WinFormsObject("groupBox1").WinFormsObject("txtURL").Click
      Aliases.cwConsole.WinFormsObject("frmSpecifiedUrls").WinFormsObject("groupBox1").WinFormsObject("txtURL").SetText("Chrome.exe")
      Aliases.cwConsole.WinFormsObject("frmSpecifiedUrls").WinFormsObject("groupBox1").WinFormsObject("btnAddUrl").ClickButton
      Aliases.cwConsole.WinFormsObject("frmSpecifiedUrls").WinFormsObject("btnApply").ClickButton
      Aliases.cwConsole.WinFormsObject("frmSpecifiedUrls").WinFormsObject("btnOK").ClickButton
      frmReportOptions.btnRunReport.ClickButton
    Else
      Aliases.cwConsole.frmCrystalReport.Close
    End If
  Else
    Aliases.cwConsole.dlgBrowseReporter.btnOK.ClickButton
  End If

  Sleep 2000

End Function

 

Thanks and regards,
Amal

Codework Inc. 

amalashok@codework-solutions.com

  • amalcodework's avatar
    amalcodework
    5 years ago

    Hi Robert, 

    Sorry for the delayed response. 

     

    I was playing around with the code and finally, I got a solution for this. I've replaced WaitAliasChild with WaitWinFormsObject method. This is working as expected and my code is successful now. 

     

    Here is the new code which fixed the issues. 

    If Aliases.cwConsole.WaitWinFormsObject("frmCrystalReport", 30000).Exists Then

     

    Thank you very much for your ideas and for helping me to fix the issues. I will be testing the new code and will get back to you if I get any further issues. 

16 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero
    • Uncheck the Stop On Error option in the Project properties page
    • 'The object with the specified attributes does not exist.' error will be displayed when you use Full name (starts with Sys.Process *)  instead of the mapped object.
    • amalcodework's avatar
      amalcodework
      Occasional Contributor

      Hello Shankar, 

      Thanks for your reply. 

       

      • I tried the unchecking 'Stop On Error' and it did work. But, I'd like to stop the script execution on error windows. If I disable this thing the script may not stop when there is actually an error object. Is that right? 
      • I've tried using the mapped name and I got the same error message for many times. That's why I tried using the full name. 
      If Not Aliases.cwConsole.frmCrystalReport.Exists Then
      • shankar_r's avatar
        shankar_r
        Community Hero

        It is fine if you enabled Stop On Error

         

        The actual problem is occurring on this line,

        Set Rep = Sys.Process("cwConsole.exe").winformsObject("frmCrystalReport")

        not in 

        If Not Aliases.cwConsole.frmCrystalReport.Exists Then

         

        replace like below and try it.

        Set Rep = Aliases.cwConsole.frmCrystalReport