| || |
Exists or not Exists
I don't know why I cant get this Exists to work.
We have a Java program that when you go between screen a pop-up screen called "Wait for Task", Kind of like a progress bar between each step, but its its own JDialog box.
Sometimes this Wait for task box is on the screen for 2 seconds sometimes 15 seconds.
A pain when trying to regression test.
I wrote a function to call that pretty just sleeps while this box is on the screen.
But seems to fail or get a false every time now. It can't find the Wait for Task.
If _desktop.Exists("Card Report") '<----This Exists works just fine.
For seconds = 0 To timeout
If _desktop.JFrame("Card Report").Exists("Wait For Task") = True Then 'I'm trying to find the Wait For task Under the JFrame Object Card Report.
I even run MsgBox( _desktop.JFrame("Card Report").Exists("Wait For Task"))
I even try just .Exists("Wait For Task")
I have tried using just the Locator. //JDialog whatever
But if I do
With .JDialog("Wait For Task")
It works just fine.
So its knows its there, but I can't get the Exits to find it.
Last edited by tubaloth; 07-18-2013 at 08:58 AM.
Consider the following VB.NET script (in the Workbench), what this does is to execute Notepad and show the About dialog, I then recorded closing the dialog.
The code was modified to remove the closing of the dialog (for testing purposes). Then I added the code to Sleep for 500ms (to give the dialog a chance to appear), then if the dialog exists wait for it to disappear (timeout of 30 seconds).
With _desktop.Window("Untitled - Notepad")
' Code that closes dialog removed.
'With .Dialog("About Notepad Dialog")
' .Move(New Point(151, 159))
' Wait half a second for the dialog to appear
If ( True = .Exists("About Notepad Dialog")) Then
' Wait for the dialog to disappear
.Dialog("About Notepad Dialog").WaitForDisappearance(30000)
' Show that we saw it disappear
Thanks... I didn't know about the WaitForDisappearance I might try that.
The problem I think I'm having is back to the object map. I have Process A that does things. During this process it has the "Wait For Task" dialog box.
I actually have Process B and C Both doing different things, but they all have a Wait for Task Dialog box. The funny thing is the Process A Wait for Task dialog box is independed of the screen. (So that Wait for task object doesn't fall under the Process A Dialog box object). But for Process B and C it does fall under the Object or so I thought.
So to explain it using your Notepad example. It would be like having three programs all having the same About notepad Dialog but trying to figure out which one actually exsits.
In Test Partner this was easy. While the Wait for Task was open I would pause. But in Silk Test (and the Object Map) Each Process has its own wait for task. So for me to check that it exsits I have to be "under" that process or Object map.
This makes it harder to write one function to wait for task that works for all screens.
As I said before the wait for task that happens on Process A is independent of that Object.
I think my problem is that during Process B that first wait for task (that one I care about the most) is also independed of the Process Object. But later on in the process it does fall under it. I know its strange.
Thats the only way I got it to work. Was to switch it over to be like the Process A wait for Task.
That was just me rambiling on. No real usefull information except for me.
You should still be able to use the WaitForDisappearance() from the desktop because Silk Test searches down the tree (as such) until it finds the window.
Consider the following, we have the similar code to the previous example, this time I am using a raw locator with a wildcard to find the About dialog.
There are 2 pieces of code that show the About dialog, one from the Notepad and the other from the Calculator, different processes.
The code that finds the About dialog works for both because Silk Test is searching for the dialog from the desktop not from the application (notepad or calc).
Does that make sense?
Public Sub Main()
'With _desktop.Window("Untitled - Notepad")
' .TextField("TextField").TypeKeys("Hello World<Enter>")
' .MenuItem("About Notepad").Select()
' Works for either About dialog, wildcard was used where the name of the application would appear.
Dim locator As String = "//Dialog[@caption='About *']"
If ( True = .Exists(locator)) Then
Yeah I have been playing around wtih it. Trying to make it easier.
I do think the WaitForDisappearance is the way to go. But like I said its just finding the correct box. I'm trying to do it more from the desktop. Like I said before there is one under the desktop, but a couple of screens have there own.
Wait For Task
My worry now is that I'll be on Screen 1 or Screen 2 and it will get tripped by the top level waitForTask (and thus fail)
I'll keep playing around with it.
Side note for eggbox. I have noticed when write a script in the Silk Test program.
instead of me typing it out I'll just link to request I sent.
dot menu doesn't show up consistently ? Borland Customer Feature Feedback
Have you noticed this happening? Its probably one of the biggest frustrations.
I thought that .exists() is for data dictionaries. .Exist() is for object existance.
VBScript isn't case sensitive for identifiers. But there is a coding convention that dictates when you should use upper or lower case.
I have and I think I know why this happens, if you include a script as a reference you will probably see this issue because there is more than one instance of the variable (_desktop) in scope so the editor doesn't know which one you mean so it does nothing. If you are including script references that only contain utility code then you can safely remove the Sub Main and the _desktop because they will never be used, this should help.
Originally Posted by tubaloth
I have a message above about exists. Sorry. I thought I was in the QTP forum.