1

I want to be able to recognize the Eclipse window, which is always already open, so I won't ever need to open it with SilkTest. Is there a way that I can set the base state to be a window that's always going to be open? It seems the way to set the base state also designates the executable for it to open. The executable won't necessarily always be in the same location, and it would be a pain to configure that.

Is this possible?

I've already tried desktop.<Window>find("//Window[@caption='Java EE*']");, which doesn't work.

Tom
  • 221
  • 4
  • 15

1 Answers1

2

The base state in Silk Test does multiple things:

  • Tell Silk Test which application you want to test
  • Find the application if it is running
  • Otherwise it will start the application

Obviously you don't need the third step, but the other two are still required. I suggest using *eclipse.exe as executable pattern and the locator "//Window[@caption='Java EE*']" which you already have, if you then execute the base state it should return you the main window of Eclipse and you're good to go.

tehlexx
  • 2,821
  • 16
  • 29
  • That solved my initial problem. However, it seems like when I start up a test, it changes something about Eclipse such that I can't refer to it by the same BaseState in subsequent tests. The tests are completely independent of each other. The only thing that stays active is the SilkTest Open Agent. Essentially, the first time I run a test using the base state you've described, it works fine. Subsequent attempts, however, fail to find Eclipse, even though, as far as I'm concerned, nothing's changed. Any ideas? – Tom Nov 19 '12 at 19:41
  • I'd guess that closing the eclipse window from the first test takes longer than Silk Test realizes - the base state of the second test might then find the old instance which is about to disappear. To verify that theory you could use `closeSynchron()` and maybe also add a sleep with a sufficiently large time span after the close (so it's guaranteed that the old window is gone). – tehlexx Nov 20 '12 at 11:24
  • It doesn't actually close the window. It's a thread that runs a test using SilkTest objects and some other stuff. It runs within Eclipse. I want to access Eclipse because there is a JBoss server running. Depending on what the test does to my application, the server needs to be reset sometimes. I'm trying to accomplish this programmatically through Silk. It's as if the executable changes after I run the first test. Right now, the only way to reset the reference to the Eclipse window is to restart Eclipse and Open Agent. Extra steps I'd like to avoid. – Tom Nov 20 '12 at 12:22
  • I'm not sure if I understand what you're trying to do. Are you setting a difference executable pattern? If that's the case, I'd rather add multiple patterns than unhooking/rehooking the application. Also, when you say you need to reset the reference to the Eclipse window, do you mean you get an `InvalidObjectHandleException`? If that's the case, you need to do another find to get a new object handle. – tehlexx Nov 20 '12 at 12:36
  • It required a lot of further explanation, so I created another, more specific question [here](http://stackoverflow.com/questions/13473832/silktest-base-state-unrecognized-after-consecutive-tests-run), if you care to take a look. – Tom Nov 20 '12 at 13:06