连续测试运行后,SilkTest基本状态无法识别

在我的测试环境中,我们有一些执行某些操作的类,其中一些使用SilkTest。 测试过程由我们解析的XML文件定义,转换为ActionImpl类,并执行操作。 例如,以下内容将登录我们的应用程序,切换用户,然后重新启动服务器:

       

对于restartServer操作,代码最终会调用以下方法,该方法使用当前运行测试的eclipse.exe创建restartServer

 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; } 

假设我正在进行当天的第一次测试。 我刚开始工作,决定进行测试。 如果代码进入restartServer操作并调用restartServerInEclipse() ,它将识别当前正在运行的eclipse.exe ,并在我告诉它的任何Silk对象上成功执行任何Silk方法。

但是,在没有退出Eclipse或Open Agent的情况下,在测试完成后,如果我再次运行相同的测试,如全新对象,全新测试线程,测试运行并停止,我单击Eclipse中的绿色运行按钮再次,当它到达BaseState eclipseBaseState = new BaseState(...)代码时,我得到以下错误:

 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) 

两秒前完全正常工作的基本状态现在不正确。 一旦初始设置了基本状态,就好像Eclipse的某些内容会发生变化,因此无法重新识别它。

解决这个问题的唯一方法是重新启动Eclipse和Open Agent,但即使这样做有时也不起作用,偶尔会遇到OA的一些许可证服务器问题,这需要重新启动计算机。

从您发布的日志文件中,我可以看到您在测试eclipse.exeiexplore.exe之间切换。 您的脚本当前构建的方式是一个或另一个。 这意味着只要切换到Internet Explorer,Silk Test就会从Eclipse中分离出来,并且将不再识别该窗口。

由于您无论如何都是通过其他机制启动应用程序,我建议使用attach方法,该方法是累积的,并且会添加模式而不是替换它,因此您将避免在应用程序之间切换。

 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");