SilkTest base state unrecognized after consecutive tests run

不羁岁月 提交于 2019-12-08 03:53:00

问题


In my testing environment, we have classes that perform certain actions, some of them using SilkTest stuff. The test procedures are defined by XML files that we parse, turn into ActionImpl classes, and perform stuff with. For example, the following will login to our app, switch users, and then restart the server:

<Script refBean="validateState" retry="false">
    <DataGroups>
        <Step action="log" mod="5.10.13 - Step 1" />
        <Step action="switchUsers" target="mlane" />
        <Step action="restartServer" />
    </DataGroups>
</Script>

In the case of the restartServer action, the code eventually calls the following method, which creates a BaseState using the currently running eclipse.exe that the test is running in.

private PassFail restartServerInEclipse() {
    Desktop desktop = new Desktop();
    BaseState eclipseBaseState = new BaseState("*eclipse.exe", "/Shell[@caption='Java EE*']", TechDomain.SWT, TechDomain.XBROWSER, TechDomain.WIN32);
    desktop.executeBaseState(eclipseBaseState);
    // Do some stuff, like finding CTabItem objects, clicking them, etc.
    return passFail;
}

Let's say I'm running the first test of the day. I just got to work, and decided to run a test. If the code gets to a restartServer action, and calls restartServerInEclipse(), it'll recognize the currently running eclipse.exe, and successfully perform any Silk methods on any Silk objects that I tell it to.

However, without exiting Eclipse or Open Agent, after a test has finished, if I run the same test again, as in, entirely new objects, entirely new test thread, the test ran and stopped, and I clicked the green run button in Eclipse again, I get the following error when it gets to the BaseState eclipseBaseState = new BaseState(...) code:

com.borland.silktest.jtf.common.LaunchApplicationFailedException: Failed to start application '*eclipse.exe' in working directory 'null'. The system cannot find the file specified.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.borland.silktest.jtf.agent.ExceptionTranslatorUtil.createException(ExceptionTranslatorUtil.java:60)
    at com.borland.silktest.jtf.agent.ExceptionTranslatorUtil.translate(ExceptionTranslatorUtil.java:37)
    at com.borland.silktest.jtf.agent.JtfModule.executeBaseState_aroundBody39$advice(JtfModule.java:121)
    at com.borland.silktest.jtf.agent.JtfModule.executeBaseState(JtfModule.java:1)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:77)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy24.executeBaseState(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:205)
    at org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:38)
    at org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:78)
    at org.springframework.remoting.rmi.RmiBasedExporter.invoke(RmiBasedExporter.java:72)
    at org.springframework.remoting.rmi.RmiInvocationWrapper.invoke(RmiInvocationWrapper.java:72)
    at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
    at sun.rmi.transport.Transport$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    at org.springframework.remoting.support.RemoteInvocationUtils.fillInClientStackTraceIfPossible(RemoteInvocationUtils.java:47)
    at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:351)
    at org.springframework.remoting.rmi.RmiClientInterceptor.invoke(RmiClientInterceptor.java:258)
    at com.borland.silktest.startservice.RmiConnectionUtil$1.invoke(RmiConnectionUtil.java:134)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy0.executeBaseState(Unknown Source)
    at com.borland.silktest.jtf.Agent.executeBaseState(Agent.java:452)
    at com.borland.silktest.jtf.BaseState.execute(BaseState.java:298)
    at com.borland.silktest.jtf.Desktop.executeBaseState(Desktop.java:69)
    at scripts.misc.validation.action.RestartServerActionImpl.restartServerInEclipse(RestartServerActionImpl.java:62)
    at scripts.misc.validation.action.RestartServerActionImpl.evaluate(RestartServerActionImpl.java:25)
    at scripts.misc.validation.ValidateState.evaluateStep(ValidateState.java:108)
    at scripts.misc.validation.ValidateState.script(ValidateState.java:131)
    at scripts.base.BaseScript.runWithRetries(BaseScript.java:204)
    at scripts.base.BaseScript.runIt(BaseScript.java:312)
    at suite.MainThread.script(MainThread.java:667)
    at suite.MainThread.run(MainThread.java:281)

The base state that worked completely fine two seconds previous is now incorrect. As if something about Eclipse changes once the base state is initially set, so it can't re-recognize it.

The only way to get around this is to restart Eclipse and Open Agent, but even that doesn't work sometimes, and I run into some license server issues with OA occasionally, which requires a computer reboot.


回答1:


From the log file you posted, I can see that you are switching between testing eclipse.exe and iexplore.exe. The way your script is currently built it is either one or the other. This means that as soon as you switch to Internet Explorer, Silk Test is detaching from Eclipse and will no longer recognize the window.

Since you are starting your applications through other mechanisms anyway, I suggest the attach method, which is cumulative and will add the pattern instead of replacing it, so you'll avoid switching between the applications.

Desktop desktop = new Desktop();
desktop.attach("*\\eclipse.exe", TechDomain.SWT, TechDomain.XBROWSER, TechDomain.WIN32);
desktop.attach("*\\iexplore.exe", TechDomain.SWT, TechDomain.XBROWSER, TechDomain.WIN32);
Shell eclipse = desktop.find("/Shell[@caption='Java EE*']");
BrowserApplication browserApp = desktop.find("/BrowserApplication");


来源:https://stackoverflow.com/questions/13473832/silktest-base-state-unrecognized-after-consecutive-tests-run

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!