'The object with the specified attributes does not exist.' error while checking for a CrystalReport
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
'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
Amal G A
Codework Inc.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 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.
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Amal G A
Codework Inc.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Common problem:
How do you check the "Exists" property of an object that does not exist? If the object does not exist, there is no object to have an "Exists" property. To check for "Exists", you need to either use a "Find" method to search for the object or a WaitNNN method of some sort.
I'd replace the code below with the following.
If Not Aliases.cwConsole.WaitAliasChild('frmCrystalReport', 5000).Exists Then
WaitAliasChild will wait the indicated number of milliseconds for the object to return. If it returns sooner than that time, the object is returned immediately and the method continues without waiting the full time. If the timeout expires, a "stub" object is returned which consists of ONLY the "Exists" property with a value of "False".
This is the recommended best practice method of checking for existance.
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for this Robert Martin.
It works when the Crystal Report object does not exist. But when it is available the checking fails again.
Scenario #1 - Crystal Report object does not exist. (Success)
Both the 'IF' and 'IF NOT' conditions are working fine. Got the expected result.
Scenario #2 - Crystal Report object exists. (Failed)
IF and IF NOT conditions gave the wrong result. It shows similar to Scenario 1.
My code is ready when Scenario #2 works.
Amal G A
Codework Inc.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for this Robert Martin.
It works when the Crystal Report object does not exist. But when it is available the checking fails again.
Scenario 1 - Crystal Report object does not exist. (Success)
Both the 'IF' and 'IF NOT' conditions are working fine. Got the expected result.
Scenario 2 - Crystal Report object exists. (Failed)
IF and IF NOT conditions gave the wrong result. It shows similar to Scenario 1.
My code is ready when Scenario 2 works.
Amal G A
Codework Inc.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Shankar,
Yes, I tried this as well. The same error again.
Aliases.cwConsole.frmCrystalReport.Exists
I'm trying the steps provided by Robert Martin.
Amal G A
Codework Inc.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Robert,
Here is the code.
If Not Aliases.cwConsole.WaitAliasChild("frmCrystalReport", 5000).Exists Then "Do this" Else "Do that" End If
OR
If Aliases.cwConsole.WaitAliasChild("frmCrystalReport", 5000).Exists Then "Do that" Else "Do this" End If
Amal G A
Codework Inc.
