Ask a Question

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

SOLVED
amalcodework
Occasional Contributor

'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

Thanks & Regards,
Amal G A
Codework Inc.
16 REPLIES 16

I'm not sure I understand. So, you're saying that, if the object does not exist, you're getting your "else" statement but if the object DOES exist, you're still getting your else statement?

How do you know the object exists? Because, if you're getting the else statement, then TestComplete thinks it doesn't. Which... to me... means that there's something wrong in your mapping, potentially, for frmCrystalReport where TestComplete is not finding it... OR.... 5 seconds isn't long enough. The 5000 is a MAXIMUM timeout. So, you could, potentially, set it to something astronomically huge like 120000 which is a 2 minute wait time. If the object returns BEFORE the timeout, it returns IMMEDIATELY and does not wait the full time.

Try bumping that timeout setting up to something higher to see if things work better. If it still does not, then go back and double check that frmCrystalReport is being properly identified by the NameMapping engine.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
amalcodework
Occasional Contributor

Hi Robert, 

I tried extending the timeout to 20 seconds earlier. Now, as you mentioned, I tried with 2-minute Timeout. Still, it is not giving the right output.

 

I think it is not waiting for the CR object. When I checked with the breakpoints, it is passing to the next statement without waiting for the timeout period. 

 

Let me make it clear: 

	If Aliases.cwConsole.WaitAliasChild("frmCrystalReport", 10000).Exists Then
		Log.Message("Crystal Report")
	Else 
		Log.Error("Error message")
	End If

In this code, I always get Log.Message("Crystal Report") as the result even if the Crystal Report object is actually unavailable.

I'm not getting the Else statement for any of the scenarios. 

 

Here is a screenshot of the Object Properties window of the Crystal Report. CR.png

Thanks & Regards,
Amal G A
Codework Inc.

Can you post the properties you are using in NameMapping for that object? It seems like you may have something dynamic being used that is changing from test run to test run.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

One other item of note.

An object can "Exist" but not be visible on screen... so, it's entirely possible that, while you can't see the object on screen, it may exist and so satisfy the condition.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
amalcodework
Occasional Contributor

Hi Richard, 

I agree with that point. 

 

But my doubt is that when I use, 

Aliases.cwConsole.frmCrystalReport.Exists

OR
Aliases.cwConsole.WinFormsObject("frmCrystalReport").Exists

instead of, 

Aliases.cwConsole.WaitAliasChild("frmCrystalReport", 10000).Exists

it showed the following error when the Crystal Report is unavailable, 

The object with the specified attributes does not exist.

That was my original concern, 

 

When I used WaitAliasChild method as per your suggestion, it is not showing the error. But it satisfies the condition when the object does not exist. 

 

Here is the screenshot of the Object Property window for the Crystal Reports viewer. 

CR.png

Thanks & Regards,
Amal G A
Codework Inc.

I don't need the screenshot of the properties... I need a screenshot of the NameMapping node showing what properties you're using for object identification.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
amalcodework
Occasional Contributor

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. 

Thanks & Regards,
Amal G A
Codework Inc.
cancel
Showing results for 
Search instead for 
Did you mean: